From ace6b2d8f39478c8f43816b6cd951124a7e549cd Mon Sep 17 00:00:00 2001 From: alishakawaguchi Date: Fri, 19 Jul 2024 10:17:03 -0700 Subject: [PATCH] Fix javascript transformer docs examples (#2317) --- docs/.prettierignore | 1 + .../gen-javascript-transformer.md | 767 ++++++++++-------- .../mgmt/v1alpha1/connection_data.proto.mdx | 74 +- .../neosync_js_transformer_docs_generator.go | 28 +- 4 files changed, 494 insertions(+), 376 deletions(-) diff --git a/docs/.prettierignore b/docs/.prettierignore index bbd0255ab1..7eb458e0be 100644 --- a/docs/.prettierignore +++ b/docs/.prettierignore @@ -7,3 +7,4 @@ tsconfig.json charts dev protos +docs/transformers/gen-javascript-transformer.md diff --git a/docs/docs/transformers/gen-javascript-transformer.md b/docs/docs/transformers/gen-javascript-transformer.md index 1cb115563f..4cb886b7c8 100644 --- a/docs/docs/transformers/gen-javascript-transformer.md +++ b/docs/docs/transformers/gen-javascript-transformer.md @@ -5,7 +5,7 @@ hide_title: false id: javascript description: Learn about Neosync's javascript transformer --- - + @@ -23,12 +23,16 @@ Each transformer function accepts a value and a configuration object as argument The source column value is accessible via the `value` keyword, while additional columns can be referenced using `input.{column_name}`.
+ + ### transformCharacterScramble + + **Parameters** **Value** @@ -37,27 +41,29 @@ Description: Value that will be transformed **Config** -| Field | Type | Default | Required | Description | -| ----------------- | ------ | ------- | -------- | ----------- | -| userProvidedRegex | string | | false | - -
+| Field | Type | Default | Required | Description | +| -------- | ---- | ------- | -------- | ----------- | +| userProvidedRegex | string | | false |
**Example** ```javascript -const newValue = transformCharacterScramble(value, { - userProvidedRegex: '', + +const newValue = neosync.transformCharacterScramble(value, { + userProvidedRegex: "", }); -``` +```
+ ### transformE164PhoneNumber + + **Parameters** **Value** @@ -66,29 +72,31 @@ Description: Value that will be transformed **Config** -| Field | Type | Default | Required | Description | -| -------------- | ----- | ------- | -------- | ----------- | -| preserveLength | bool | | true | -| maxLength | int64 | | false | - -
+| Field | Type | Default | Required | Description | +| -------- | ---- | ------- | -------- | ----------- | +| preserveLength | bool | | true | +| maxLength | int64 | | false |
**Example** ```javascript -const newValue = transformE164PhoneNumber(value, { - preserveLength: false, - maxLength: 1, + +const newValue = neosync.transformE164PhoneNumber(value, { + preserveLength: false, + maxLength: 1, }); -``` +```
+ ### transformEmail + + **Parameters** **Value** @@ -97,41 +105,43 @@ Description: Value that will be transformed **Config** -| Field | Type | Default | Required | Description | -| ------------------ | ------ | -------- | -------- | ----------- | -| email | any | | false | -| preserveLength | bool | false | true | -| preserveDomain | bool | false | true | -| excludedDomains | any | [] | true | -| maxLength | int64 | 10000 | true | -| seed | int64 | | false | -| emailType | string | 'uuidv4' | true | -| invalidEmailAction | string | 'reject' | true | - -
+| Field | Type | Default | Required | Description | +| -------- | ---- | ------- | -------- | ----------- | +| email | any | | false | +| preserveLength | bool | false | true | +| preserveDomain | bool | false | true | +| excludedDomains | any | [] | true | +| maxLength | int64 | 10000 | true | +| seed | int64 | | false | +| emailType | string | 'uuidv4' | true | +| invalidEmailAction | string | 'reject' | true |
**Example** ```javascript -const newValue = transformEmail(value, { - email: '', - preserveLength: false, - preserveDomain: false, - excludedDomains: [], - maxLength: 10000, - seed: 1, - emailType: 'uuidv4', - invalidEmailAction: 'reject', + +const newValue = neosync.transformEmail(value, { + email: "", + preserveLength: false, + preserveDomain: false, + excludedDomains: [], + maxLength: 10000, + seed: 1, + emailType: 'uuidv4', + invalidEmailAction: 'reject', }); -``` +```
+ ### transformFirstName + + **Parameters** **Value** @@ -140,31 +150,33 @@ Description: Value that will be transformed **Config** -| Field | Type | Default | Required | Description | -| -------------- | ----- | ------- | -------- | ----------- | -| maxLength | int64 | 10000 | true | -| preserveLength | bool | false | true | -| seed | int64 | | false | - -
+| Field | Type | Default | Required | Description | +| -------- | ---- | ------- | -------- | ----------- | +| maxLength | int64 | 10000 | true | +| preserveLength | bool | false | true | +| seed | int64 | | false |
**Example** ```javascript -const newValue = transformFirstName(value, { - maxLength: 10000, - preserveLength: false, - seed: 1, + +const newValue = neosync.transformFirstName(value, { + maxLength: 10000, + preserveLength: false, + seed: 1, }); -``` +```
+ ### transformFloat64 + + **Parameters** **Value** @@ -173,35 +185,37 @@ Description: Value that will be transformed **Config** -| Field | Type | Default | Required | Description | -| --------------------- | ------- | ------- | -------- | ----------- | -| randomizationRangeMin | float64 | | true | -| randomizationRangeMax | float64 | | true | -| precision | int64 | | false | -| scale | int64 | | false | -| seed | int64 | | false | - -
+| Field | Type | Default | Required | Description | +| -------- | ---- | ------- | -------- | ----------- | +| randomizationRangeMin | float64 | | true | +| randomizationRangeMax | float64 | | true | +| precision | int64 | | false | +| scale | int64 | | false | +| seed | int64 | | false |
**Example** ```javascript -const newValue = transformFloat64(value, { - randomizationRangeMin: 1.12, - randomizationRangeMax: 1.12, - precision: 1, - scale: 1, - seed: 1, + +const newValue = neosync.transformFloat64(value, { + randomizationRangeMin: 1.12, + randomizationRangeMax: 1.12, + precision: 1, + scale: 1, + seed: 1, }); -``` +```
+ ### transformFullName + + **Parameters** **Value** @@ -210,31 +224,33 @@ Description: Value that will be transformed **Config** -| Field | Type | Default | Required | Description | -| -------------- | ----- | ------- | -------- | ----------- | -| maxLength | int64 | 10000 | true | -| preserveLength | bool | false | true | -| seed | int64 | | false | - -
+| Field | Type | Default | Required | Description | +| -------- | ---- | ------- | -------- | ----------- | +| maxLength | int64 | 10000 | true | +| preserveLength | bool | false | true | +| seed | int64 | | false |
**Example** ```javascript -const newValue = transformFullName(value, { - maxLength: 10000, - preserveLength: false, - seed: 1, + +const newValue = neosync.transformFullName(value, { + maxLength: 10000, + preserveLength: false, + seed: 1, }); -``` +```
+ ### transformInt64 + + **Parameters** **Value** @@ -243,29 +259,31 @@ Description: Value that will be transformed **Config** -| Field | Type | Default | Required | Description | -| --------------------- | ----- | ------- | -------- | ----------- | -| randomizationRangeMin | int64 | | true | -| randomizationRangeMax | int64 | | true | - -
+| Field | Type | Default | Required | Description | +| -------- | ---- | ------- | -------- | ----------- | +| randomizationRangeMin | int64 | | true | +| randomizationRangeMax | int64 | | true |
**Example** ```javascript -const newValue = transformInt64(value, { - randomizationRangeMin: 1, - randomizationRangeMax: 1, + +const newValue = neosync.transformInt64(value, { + randomizationRangeMin: 1, + randomizationRangeMax: 1, }); -``` +```
+ ### transformInt64PhoneNumber + + **Parameters** **Value** @@ -274,27 +292,29 @@ Description: Value that will be transformed **Config** -| Field | Type | Default | Required | Description | -| -------------- | ---- | ------- | -------- | ----------- | -| preserveLength | bool | | true | - -
+| Field | Type | Default | Required | Description | +| -------- | ---- | ------- | -------- | ----------- | +| preserveLength | bool | | true |
**Example** ```javascript -const newValue = transformInt64PhoneNumber(value, { - preserveLength: false, + +const newValue = neosync.transformInt64PhoneNumber(value, { + preserveLength: false, }); -``` +```
+ ### transformLastName + + **Parameters** **Value** @@ -303,31 +323,33 @@ Description: Value that will be transformed **Config** -| Field | Type | Default | Required | Description | -| -------------- | ----- | ------- | -------- | ----------- | -| maxLength | int64 | 10000 | true | -| preserveLength | bool | false | true | -| seed | int64 | | false | - -
+| Field | Type | Default | Required | Description | +| -------- | ---- | ------- | -------- | ----------- | +| maxLength | int64 | 10000 | true | +| preserveLength | bool | false | true | +| seed | int64 | | false |
**Example** ```javascript -const newValue = transformLastName(value, { - maxLength: 10000, - preserveLength: false, - seed: 1, + +const newValue = neosync.transformLastName(value, { + maxLength: 10000, + preserveLength: false, + seed: 1, }); -``` +```
+ ### transformString + + **Parameters** **Value** @@ -336,31 +358,33 @@ Description: Value that will be transformed **Config** -| Field | Type | Default | Required | Description | -| -------------- | ----- | ------- | -------- | ----------- | -| preserveLength | bool | false | true | -| minLength | int64 | 1 | true | -| maxLength | int64 | 20 | true | - -
+| Field | Type | Default | Required | Description | +| -------- | ---- | ------- | -------- | ----------- | +| preserveLength | bool | false | true | +| minLength | int64 | 1 | true | +| maxLength | int64 | 20 | true |
**Example** ```javascript -const newValue = transformString(value, { - preserveLength: false, - minLength: 1, - maxLength: 20, + +const newValue = neosync.transformString(value, { + preserveLength: false, + minLength: 1, + maxLength: 20, }); -``` +```
+ ### transformStringPhoneNumber + + **Parameters** **Value** @@ -369,23 +393,23 @@ Description: Value that will be transformed **Config** -| Field | Type | Default | Required | Description | -| -------------- | ----- | ------- | -------- | ----------- | -| preserveLength | bool | | true | -| maxLength | int64 | | true | - -
+| Field | Type | Default | Required | Description | +| -------- | ---- | ------- | -------- | ----------- | +| preserveLength | bool | | true | +| maxLength | int64 | | true |
**Example** ```javascript -const newValue = transformStringPhoneNumber(value, { - preserveLength: false, - maxLength: 1, + +const newValue = neosync.transformStringPhoneNumber(value, { + preserveLength: false, + maxLength: 1, }); -``` +```
+ ## Generators Neosync's generator functions enable the creation of various data values, facilitating the generation of realistic and diverse data for @@ -394,627 +418,697 @@ Each generator function accepts a configuration object as an argument.
+ ### generateBool + + **Parameters** **Config** -| Field | Type | Default | Required | Description | -| ----- | ----- | ------- | -------- | ----------- | -| seed | int64 | | true | - +| Field | Type | Default | Required | Description | +| -------- | ---- | ------- | -------- | ----------- | +| seed | int64 | | true |
**Example** ```javascript -const newValue = generateBool({ - seed: 1, + +const newValue = neosync.generateBool({ + seed: 1, }); -``` +```
+ ### generateCardNumber + + **Parameters** **Config** -| Field | Type | Default | Required | Description | -| --------- | ---- | ------- | -------- | ----------- | -| validLuhn | bool | | true | - +| Field | Type | Default | Required | Description | +| -------- | ---- | ------- | -------- | ----------- | +| validLuhn | bool | | true |
**Example** ```javascript -const newValue = generateCardNumber({ - validLuhn: false, + +const newValue = neosync.generateCardNumber({ + validLuhn: false, }); -``` +```
+ ### generateCategorical + + **Parameters** **Config** -| Field | Type | Default | Required | Description | -| ---------- | ------ | ------- | -------- | ----------- | -| categories | string | | true | - +| Field | Type | Default | Required | Description | +| -------- | ---- | ------- | -------- | ----------- | +| categories | string | | true |
**Example** ```javascript -const newValue = generateCategorical({ - categories: '', + +const newValue = neosync.generateCategorical({ + categories: "", }); -``` +```
+ ### generateCity + + **Parameters** **Config** -| Field | Type | Default | Required | Description | -| --------- | ----- | ------- | -------- | ----------- | -| maxLength | int64 | | true | - +| Field | Type | Default | Required | Description | +| -------- | ---- | ------- | -------- | ----------- | +| maxLength | int64 | | true |
**Example** ```javascript -const newValue = generateCity({ - maxLength: 1, + +const newValue = neosync.generateCity({ + maxLength: 1, }); -``` +```
+ ### generateEmail + + **Parameters** **Config** -| Field | Type | Default | Required | Description | -| --------- | ------ | -------- | -------- | ----------- | -| maxLength | int64 | 100000 | true | -| emailType | string | 'uuidv4' | true | -| seed | int64 | | false | - +| Field | Type | Default | Required | Description | +| -------- | ---- | ------- | -------- | ----------- | +| maxLength | int64 | 100000 | true | +| emailType | string | 'uuidv4' | true | +| seed | int64 | | false |
**Example** ```javascript -const newValue = generateEmail({ - maxLength: 100000, - emailType: 'uuidv4', - seed: 1, + +const newValue = neosync.generateEmail({ + maxLength: 100000, + emailType: 'uuidv4', + seed: 1, }); -``` +```
+ ### generateFirstName + + **Parameters** **Config** -| Field | Type | Default | Required | Description | -| --------- | ----- | ------- | -------- | ----------- | -| maxLength | int64 | 10000 | true | -| seed | int64 | | true | - +| Field | Type | Default | Required | Description | +| -------- | ---- | ------- | -------- | ----------- | +| maxLength | int64 | 10000 | true | +| seed | int64 | | true |
**Example** ```javascript -const newValue = generateFirstName({ - maxLength: 10000, - seed: 1, + +const newValue = neosync.generateFirstName({ + maxLength: 10000, + seed: 1, }); -``` +```
+ ### generateFloat64 + + **Parameters** **Config** -| Field | Type | Default | Required | Description | -| ------------- | ------- | ------- | -------- | ----------- | -| randomizeSign | bool | false | true | -| min | float64 | | true | -| max | float64 | | true | -| precision | int64 | | false | -| scale | int64 | | false | -| seed | int64 | | true | - +| Field | Type | Default | Required | Description | +| -------- | ---- | ------- | -------- | ----------- | +| randomizeSign | bool | false | true | +| min | float64 | | true | +| max | float64 | | true | +| precision | int64 | | false | +| scale | int64 | | false | +| seed | int64 | | true |
**Example** ```javascript -const newValue = generateFloat64({ - randomizeSign: false, - min: 1.12, - max: 1.12, - precision: 1, - scale: 1, - seed: 1, + +const newValue = neosync.generateFloat64({ + randomizeSign: false, + min: 1.12, + max: 1.12, + precision: 1, + scale: 1, + seed: 1, }); -``` +```
+ ### generateFullAddress + + **Parameters** **Config** -| Field | Type | Default | Required | Description | -| --------- | ----- | ------- | -------- | ----------- | -| maxLength | int64 | | true | - +| Field | Type | Default | Required | Description | +| -------- | ---- | ------- | -------- | ----------- | +| maxLength | int64 | | true |
**Example** ```javascript -const newValue = generateFullAddress({ - maxLength: 1, + +const newValue = neosync.generateFullAddress({ + maxLength: 1, }); -``` +```
+ ### generateFullName + + **Parameters** **Config** -| Field | Type | Default | Required | Description | -| --------- | ----- | ------- | -------- | ----------- | -| maxLength | int64 | 10000 | true | -| seed | int64 | | true | - +| Field | Type | Default | Required | Description | +| -------- | ---- | ------- | -------- | ----------- | +| maxLength | int64 | 10000 | true | +| seed | int64 | | true |
**Example** ```javascript -const newValue = generateFullName({ - maxLength: 10000, - seed: 1, + +const newValue = neosync.generateFullName({ + maxLength: 10000, + seed: 1, }); -``` +```
+ ### generateGender + + **Parameters** **Config** -| Field | Type | Default | Required | Description | -| ---------- | ----- | ------- | -------- | ----------- | -| abbreviate | bool | false | true | -| maxLength | int64 | 10000 | true | -| seed | int64 | | true | - +| Field | Type | Default | Required | Description | +| -------- | ---- | ------- | -------- | ----------- | +| abbreviate | bool | false | true | +| maxLength | int64 | 10000 | true | +| seed | int64 | | true |
**Example** ```javascript -const newValue = generateGender({ - abbreviate: false, - maxLength: 10000, - seed: 1, + +const newValue = neosync.generateGender({ + abbreviate: false, + maxLength: 10000, + seed: 1, }); -``` +```
+ ### generateInt64 + + **Parameters** **Config** -| Field | Type | Default | Required | Description | -| ------------- | ----- | ------- | -------- | ----------- | -| randomizeSign | bool | false | true | -| min | int64 | | true | -| max | int64 | | true | -| seed | int64 | | true | - +| Field | Type | Default | Required | Description | +| -------- | ---- | ------- | -------- | ----------- | +| randomizeSign | bool | false | true | +| min | int64 | | true | +| max | int64 | | true | +| seed | int64 | | true |
**Example** ```javascript -const newValue = generateInt64({ - randomizeSign: false, - min: 1, - max: 1, - seed: 1, + +const newValue = neosync.generateInt64({ + randomizeSign: false, + min: 1, + max: 1, + seed: 1, }); -``` +```
+ ### generateInt64PhoneNumber + + **Parameters** **Config** -| Field | Type | Default | Required | Description | -| ----- | ---- | ------- | -------- | ----------- | - +| Field | Type | Default | Required | Description | +| -------- | ---- | ------- | -------- | ----------- |
**Example** ```javascript -const newValue = generateInt64PhoneNumber({}); -``` +const newValue = neosync.generateInt64PhoneNumber({}); + +```
+ ### generateInternationalPhoneNumber + + **Parameters** **Config** -| Field | Type | Default | Required | Description | -| ----- | ----- | ------- | -------- | ----------- | -| min | int64 | | true | -| max | int64 | | true | - +| Field | Type | Default | Required | Description | +| -------- | ---- | ------- | -------- | ----------- | +| min | int64 | | true | +| max | int64 | | true |
**Example** ```javascript -const newValue = generateInternationalPhoneNumber({ - min: 1, - max: 1, + +const newValue = neosync.generateInternationalPhoneNumber({ + min: 1, + max: 1, }); -``` +```
+ ### generateLastName + + **Parameters** **Config** -| Field | Type | Default | Required | Description | -| --------- | ----- | ------- | -------- | ----------- | -| maxLength | int64 | 10000 | true | -| seed | int64 | | true | - +| Field | Type | Default | Required | Description | +| -------- | ---- | ------- | -------- | ----------- | +| maxLength | int64 | 10000 | true | +| seed | int64 | | true |
**Example** ```javascript -const newValue = generateLastName({ - maxLength: 10000, - seed: 1, + +const newValue = neosync.generateLastName({ + maxLength: 10000, + seed: 1, }); -``` +```
+ ### generateRandomString + + **Parameters** **Config** -| Field | Type | Default | Required | Description | -| ----- | ----- | ------- | -------- | ----------- | -| min | int64 | | true | -| max | int64 | | true | - +| Field | Type | Default | Required | Description | +| -------- | ---- | ------- | -------- | ----------- | +| min | int64 | | true | +| max | int64 | | true |
**Example** ```javascript -const newValue = generateRandomString({ - min: 1, - max: 1, + +const newValue = neosync.generateRandomString({ + min: 1, + max: 1, }); -``` +```
+ ### generateSHA256Hash + + **Parameters** **Config** -| Field | Type | Default | Required | Description | -| ----- | ---- | ------- | -------- | ----------- | - +| Field | Type | Default | Required | Description | +| -------- | ---- | ------- | -------- | ----------- |
**Example** ```javascript -const newValue = generateSHA256Hash({}); -``` +const newValue = neosync.generateSHA256Hash({}); + +```
+ ### generateSSN + + **Parameters** **Config** -| Field | Type | Default | Required | Description | -| ----- | ----- | ------- | -------- | ----------- | -| seed | int64 | | true | - +| Field | Type | Default | Required | Description | +| -------- | ---- | ------- | -------- | ----------- | +| seed | int64 | | true |
**Example** ```javascript -const newValue = generateSSN({ - seed: 1, + +const newValue = neosync.generateSSN({ + seed: 1, }); -``` +```
+ ### generateState + + **Parameters** **Config** -| Field | Type | Default | Required | Description | -| ----- | ---- | ------- | -------- | ----------- | - +| Field | Type | Default | Required | Description | +| -------- | ---- | ------- | -------- | ----------- |
**Example** ```javascript -const newValue = generateState({}); -``` +const newValue = neosync.generateState({}); + +```
+ ### generateStreetAddress + + **Parameters** **Config** -| Field | Type | Default | Required | Description | -| --------- | ----- | ------- | -------- | ----------- | -| maxLength | int64 | | true | - +| Field | Type | Default | Required | Description | +| -------- | ---- | ------- | -------- | ----------- | +| maxLength | int64 | | true |
**Example** ```javascript -const newValue = generateStreetAddress({ - maxLength: 1, + +const newValue = neosync.generateStreetAddress({ + maxLength: 1, }); -``` +```
+ ### generateStringPhoneNumber + + **Parameters** **Config** -| Field | Type | Default | Required | Description | -| ----- | ----- | ------- | -------- | ----------- | -| min | int64 | | true | -| max | int64 | | true | - +| Field | Type | Default | Required | Description | +| -------- | ---- | ------- | -------- | ----------- | +| min | int64 | | true | +| max | int64 | | true |
**Example** ```javascript -const newValue = generateStringPhoneNumber({ - min: 1, - max: 1, + +const newValue = neosync.generateStringPhoneNumber({ + min: 1, + max: 1, }); -``` +```
+ ### generateUnixTimestamp + + **Parameters** **Config** -| Field | Type | Default | Required | Description | -| ----- | ---- | ------- | -------- | ----------- | - +| Field | Type | Default | Required | Description | +| -------- | ---- | ------- | -------- | ----------- |
**Example** ```javascript -const newValue = generateUnixTimestamp({}); -``` +const newValue = neosync.generateUnixTimestamp({}); + +```
+ ### generateUsername + + **Parameters** **Config** -| Field | Type | Default | Required | Description | -| --------- | ----- | ------- | -------- | ----------- | -| maxLength | int64 | 10000 | true | -| seed | int64 | | true | - +| Field | Type | Default | Required | Description | +| -------- | ---- | ------- | -------- | ----------- | +| maxLength | int64 | 10000 | true | +| seed | int64 | | true |
**Example** ```javascript -const newValue = generateUsername({ - maxLength: 10000, - seed: 1, + +const newValue = neosync.generateUsername({ + maxLength: 10000, + seed: 1, }); -``` +```
+ ### generateUTCTimestamp + + **Parameters** **Config** -| Field | Type | Default | Required | Description | -| ----- | ---- | ------- | -------- | ----------- | - +| Field | Type | Default | Required | Description | +| -------- | ---- | ------- | -------- | ----------- |
**Example** ```javascript -const newValue = generateUTCTimestamp({}); -``` +const newValue = neosync.generateUTCTimestamp({}); + +```
+ @@ -1027,41 +1121,46 @@ Generates UUID **Config** -| Field | Type | Default | Required | Description | -| -------------- | ---- | ------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| includeHyphens | bool | true | true | Determines whether the generated UUID should include hyphens. If set to true, the UUID will be formatted with hyphens (e.g., d853d251-e135-4fe4-a4eb-0aea6bfaf645). If set to false, the hyphens will be omitted (e.g., d853d251e1354fe4a4eb0aea6bfaf645). | - +| Field | Type | Default | Required | Description | +| -------- | ---- | ------- | -------- | ----------- | +| includeHyphens | bool | true | true | Determines whether the generated UUID should include hyphens. If set to true, the UUID will be formatted with hyphens (e.g., d853d251-e135-4fe4-a4eb-0aea6bfaf645). If set to false, the hyphens will be omitted (e.g., d853d251e1354fe4a4eb0aea6bfaf645).
**Example** ```javascript -const newValue = generateUUID({ - includeHyphens: true, + +const newValue = neosync.generateUUID({ + includeHyphens: true, }); -``` +```
+ ### generateZipcode + + **Parameters** **Config** -| Field | Type | Default | Required | Description | -| ----- | ---- | ------- | -------- | ----------- | - +| Field | Type | Default | Required | Description | +| -------- | ---- | ------- | -------- | ----------- |
**Example** ```javascript -const newValue = generateZipcode({}); -``` +const newValue = neosync.generateZipcode({}); + +```
+ + \ No newline at end of file diff --git a/docs/protos/mgmt/v1alpha1/connection_data.proto.mdx b/docs/protos/mgmt/v1alpha1/connection_data.proto.mdx index 47ad4f3f4a..bcc3a628db 100644 --- a/docs/protos/mgmt/v1alpha1/connection_data.proto.mdx +++ b/docs/protos/mgmt/v1alpha1/connection_data.proto.mdx @@ -121,92 +121,104 @@ _**package** mgmt.v1alpha1_ +### `GetConnectionSchemaMapRequest` + + + +### `GetConnectionSchemaMapResponse` +.","label":"repeated","type":"SchemaMapEntry","longType":"GetConnectionSchemaMapResponse.SchemaMapEntry","fullType":"mgmt.v1alpha1.GetConnectionSchemaMapResponse.SchemaMapEntry","ismap":true,"isoneof":false,"oneofdecl":"","defaultValue":"","typeLink":"/api/mgmt/v1alpha1/connection_data.proto#getconnectionschemamapresponseschemamapentry"}]}} /> + + +### `GetConnectionSchemaMapResponse.SchemaMapEntry` + + + ### `GetConnectionSchemaRequest` - + ### `GetConnectionSchemaResponse` - + ### `GetConnectionTableConstraintsRequest` - + ### `GetConnectionTableConstraintsResponse` -.
and the list of tables that it depends on, also `.
` format.","label":"repeated","type":"ForeignKeyConstraintsEntry","longType":"GetConnectionTableConstraintsResponse.ForeignKeyConstraintsEntry","fullType":"mgmt.v1alpha1.GetConnectionTableConstraintsResponse.ForeignKeyConstraintsEntry","ismap":true,"isoneof":false,"oneofdecl":"","defaultValue":"","typeLink":"/api/mgmt/v1alpha1/connection_data.proto#getconnectiontableconstraintsresponseforeignkeyconstraintsentry"},{"name":"primary_key_constraints","description":"the key here is .
and value is the primary constraint","label":"repeated","type":"PrimaryKeyConstraintsEntry","longType":"GetConnectionTableConstraintsResponse.PrimaryKeyConstraintsEntry","fullType":"mgmt.v1alpha1.GetConnectionTableConstraintsResponse.PrimaryKeyConstraintsEntry","ismap":true,"isoneof":false,"oneofdecl":"","defaultValue":"","typeLink":"/api/mgmt/v1alpha1/connection_data.proto#getconnectiontableconstraintsresponseprimarykeyconstraintsentry"},{"name":"unique_constraints","description":"the key here is .
and value is the unique constraint","label":"repeated","type":"UniqueConstraintsEntry","longType":"GetConnectionTableConstraintsResponse.UniqueConstraintsEntry","fullType":"mgmt.v1alpha1.GetConnectionTableConstraintsResponse.UniqueConstraintsEntry","ismap":true,"isoneof":false,"oneofdecl":"","defaultValue":"","typeLink":"/api/mgmt/v1alpha1/connection_data.proto#getconnectiontableconstraintsresponseuniqueconstraintsentry"}]}} /> +.
and the list of tables that it depends on, also `.
` format.","label":"repeated","type":"ForeignKeyConstraintsEntry","longType":"GetConnectionTableConstraintsResponse.ForeignKeyConstraintsEntry","fullType":"mgmt.v1alpha1.GetConnectionTableConstraintsResponse.ForeignKeyConstraintsEntry","ismap":true,"isoneof":false,"oneofdecl":"","defaultValue":"","typeLink":"/api/mgmt/v1alpha1/connection_data.proto#getconnectiontableconstraintsresponseforeignkeyconstraintsentry"},{"name":"primary_key_constraints","description":"the key here is .
and value is the primary constraint","label":"repeated","type":"PrimaryKeyConstraintsEntry","longType":"GetConnectionTableConstraintsResponse.PrimaryKeyConstraintsEntry","fullType":"mgmt.v1alpha1.GetConnectionTableConstraintsResponse.PrimaryKeyConstraintsEntry","ismap":true,"isoneof":false,"oneofdecl":"","defaultValue":"","typeLink":"/api/mgmt/v1alpha1/connection_data.proto#getconnectiontableconstraintsresponseprimarykeyconstraintsentry"},{"name":"unique_constraints","description":"the key here is .
and value is the unique constraint","label":"repeated","type":"UniqueConstraintsEntry","longType":"GetConnectionTableConstraintsResponse.UniqueConstraintsEntry","fullType":"mgmt.v1alpha1.GetConnectionTableConstraintsResponse.UniqueConstraintsEntry","ismap":true,"isoneof":false,"oneofdecl":"","defaultValue":"","typeLink":"/api/mgmt/v1alpha1/connection_data.proto#getconnectiontableconstraintsresponseuniqueconstraintsentry"}]}} /> ### `GetConnectionTableConstraintsResponse.ForeignKeyConstraintsEntry` - + ### `GetConnectionTableConstraintsResponse.PrimaryKeyConstraintsEntry` - + ### `GetConnectionTableConstraintsResponse.UniqueConstraintsEntry` - + ### `GetConnectionUniqueConstraintsRequest` - + ### `GetConnectionUniqueConstraintsResponse` -.
and value is the unique constraint","label":"repeated","type":"TableConstraintsEntry","longType":"GetConnectionUniqueConstraintsResponse.TableConstraintsEntry","fullType":"mgmt.v1alpha1.GetConnectionUniqueConstraintsResponse.TableConstraintsEntry","ismap":true,"isoneof":false,"oneofdecl":"","defaultValue":"","typeLink":"/api/mgmt/v1alpha1/connection_data.proto#getconnectionuniqueconstraintsresponsetableconstraintsentry"}]}} /> +.
and value is the unique constraint","label":"repeated","type":"TableConstraintsEntry","longType":"GetConnectionUniqueConstraintsResponse.TableConstraintsEntry","fullType":"mgmt.v1alpha1.GetConnectionUniqueConstraintsResponse.TableConstraintsEntry","ismap":true,"isoneof":false,"oneofdecl":"","defaultValue":"","typeLink":"/api/mgmt/v1alpha1/connection_data.proto#getconnectionuniqueconstraintsresponsetableconstraintsentry"}]}} /> ### `GetConnectionUniqueConstraintsResponse.TableConstraintsEntry` - + ### `GetTableRowCountRequest` - + ### `GetTableRowCountResponse` - + ### `InitStatementOptions` - + ### `MongoSchemaConfig` - + ### `MysqlSchemaConfig` - + ### `MysqlStreamConfig` - + ### `PostgresSchemaConfig` - + ### `PostgresStreamConfig` - + ### `PrimaryConstraint` - + ### `SchemaInitStatements` - + ### `UniqueConstraint` - + ### `UniqueConstraints` - + --- ## Services @@ -226,32 +238,36 @@ This is used in handle data from a connection +#### `GetConnectionSchemaMap` +.
","requestType":"GetConnectionSchemaMapRequest","requestLongType":"GetConnectionSchemaMapRequest","requestFullType":"mgmt.v1alpha1.GetConnectionSchemaMapRequest","requestStreaming":false,"responseType":"GetConnectionSchemaMapResponse","responseLongType":"GetConnectionSchemaMapResponse","responseFullType":"mgmt.v1alpha1.GetConnectionSchemaMapResponse","responseStreaming":false,"requestTypeLink":"/api/mgmt/v1alpha1/connection_data.proto#getconnectionschemamaprequest","responseTypeLink":"/api/mgmt/v1alpha1/connection_data.proto#getconnectionschemamapresponse"}} /> + + #### `GetConnectionTableConstraints` - + #### `GetConnectionForeignConstraints` - + #### `GetConnectionPrimaryConstraints` - + #### `GetConnectionInitStatements` - + #### `GetConnectionUniqueConstraints` - + #### `GetAiGeneratedData` - + #### `GetTableRowCount` - + --- diff --git a/worker/pkg/benthos/transformers/neosync_js_transformer_docs_generator.go b/worker/pkg/benthos/transformers/neosync_js_transformer_docs_generator.go index 577957e088..75c1bc7990 100644 --- a/worker/pkg/benthos/transformers/neosync_js_transformer_docs_generator.go +++ b/worker/pkg/benthos/transformers/neosync_js_transformer_docs_generator.go @@ -121,9 +121,9 @@ func sanitizeParamDefaults(params []*transformers.BenthosSpecParam) []*transform const exampleTemplate = `{{- if eq .BenthosSpec.Type "transform" -}} {{if eq (len .BenthosSpec.Params) 0}} -const newValue = {{.BenthosSpec.Name}}(value, {}); +const newValue = neosync.{{.BenthosSpec.Name}}(value, {}); {{- else }} -const newValue = {{.BenthosSpec.Name}}(value, { +const newValue = neosync.{{.BenthosSpec.Name}}(value, { {{- range $i, $param := .BenthosSpec.Params -}} {{- if eq $param.Name "value" -}}{{ continue }}{{- end -}} {{ if $param.HasDefault }} @@ -140,9 +140,9 @@ const newValue = {{.BenthosSpec.Name}}(value, { {{- end }} {{- else if eq .BenthosSpec.Type "generate" -}} {{if eq (len .BenthosSpec.Params) 0}} -const newValue = {{.BenthosSpec.Name}}({}); +const newValue = neosync.{{.BenthosSpec.Name}}({}); {{- else }} -const newValue = {{.BenthosSpec.Name}}({ +const newValue = neosync.{{.BenthosSpec.Name}}({ {{- range $i, $param := .BenthosSpec.Params -}} {{ if $param.HasDefault }} {{$param.Name}}: {{$param.Default}}, @@ -184,8 +184,9 @@ title: Javascript Transformer slug: /transformers/javascript hide_title: false id: javascript -description: Learn about Neosync's javascript transformer +description: Learn about Neosync's javascript transformer --- + @@ -208,7 +209,7 @@ The source column value is accessible via the ` + "`value`" + ` keyword, while a - + ### {{$bs.Name}} {{$bs.Description}} @@ -225,8 +226,8 @@ Description: Value that will be transformed | -------- | ---- | ------- | -------- | ----------- | {{- range $i, $param := $bs.Params}} {{- if eq $param.Name "value" }}{{ continue }}{{- end }} -| {{$param.Name}} | {{$param.TypeStr}} | {{$param.Default}} | {{- if $param.IsOptional }} false {{- else }} true {{- end}} | {{$param.Description}} -{{- end }} +| {{$param.Name}} | {{$param.TypeStr}} | {{$param.Default}} | {{ if $param.IsOptional -}} false {{- else -}} true {{- end }} | {{$param.Description}} +{{- end -}}
**Example** @@ -248,20 +249,20 @@ Each generator function accepts a configuration object as an argument. - + ### {{$bs.Name}} {{$bs.Description}} - **Parameters** +**Parameters** **Config** | Field | Type | Default | Required | Description | | -------- | ---- | ------- | -------- | ----------- | {{range $i, $param := $bs.Params -}} -| {{$param.Name}} | {{$param.TypeStr}} | {{$param.Default}} | {{- if $param.IsOptional }} false {{- else }} true {{- end}} | {{$param.Description}} -{{end -}} +| {{$param.Name}} | {{$param.TypeStr}} | {{$param.Default}} | {{ if $param.IsOptional -}} false {{- else -}} true {{- end }} | {{ $param.Description }} +{{ end -}}
**Example** @@ -270,7 +271,8 @@ source: {{$bs.SourceFile}} {{$bs.Example}} ` + "```" + `
-{{end }}` +{{end }} +` type TemplateData struct { TransformerSpecs []*transformers.BenthosSpec