@lakeql/schema-generator 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,14 +15,27 @@ declare const metadataFieldPattern: RegExp;
15
15
  */
16
16
  declare const loadStrategies: readonly ["full_load", "full_load_append", "append"];
17
17
  type LoadStrategy = (typeof loadStrategies)[number];
18
+ /**
19
+ * Supported storage adapter types.
20
+ */
21
+ declare const storageTypes: readonly ["s3", "minio"];
22
+ type StorageType = (typeof storageTypes)[number];
18
23
  /**
19
24
  * Mutation pipeline configuration for an endpoint.
20
25
  */
21
26
  interface MutationConfig {
22
27
  /** Load strategy for the write pipeline. */
23
28
  loadStrategy: LoadStrategy;
24
- /** S3 base path for endpoint data. */
29
+ /** Storage adapter type. Defaults to "s3". */
30
+ type: StorageType;
31
+ /** S3/MinIO bucket name for endpoint data. */
32
+ bucket: string;
33
+ /** Base path for endpoint data. */
25
34
  basePath: string;
35
+ /** Optional region override (falls back to AWS_DEFAULT_REGION env var for S3). */
36
+ region?: string;
37
+ /** Optional custom endpoint. Required for MinIO, optional for S3. */
38
+ endpoint?: string;
26
39
  }
27
40
  /**
28
41
  * Zod schema for the mutation configuration object.
@@ -33,7 +46,14 @@ declare const mutationConfigSchema: z.ZodObject<{
33
46
  full_load_append: "full_load_append";
34
47
  append: "append";
35
48
  }>;
49
+ type: z.ZodDefault<z.ZodEnum<{
50
+ s3: "s3";
51
+ minio: "minio";
52
+ }>>;
53
+ bucket: z.ZodString;
36
54
  basePath: z.ZodString;
55
+ region: z.ZodOptional<z.ZodString>;
56
+ endpoint: z.ZodOptional<z.ZodString>;
37
57
  }, z.core.$strip>;
38
58
  /**
39
59
  * Zod schema for the mutation field: either `false` (disabled) or a config object (enabled).
@@ -44,7 +64,14 @@ declare const mutationSchema: z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodObj
44
64
  full_load_append: "full_load_append";
45
65
  append: "append";
46
66
  }>;
67
+ type: z.ZodDefault<z.ZodEnum<{
68
+ s3: "s3";
69
+ minio: "minio";
70
+ }>>;
71
+ bucket: z.ZodString;
47
72
  basePath: z.ZodString;
73
+ region: z.ZodOptional<z.ZodString>;
74
+ endpoint: z.ZodOptional<z.ZodString>;
48
75
  }, z.core.$strip>]>;
49
76
  /**
50
77
  * Supported primitive types for field definitions.
@@ -118,7 +145,14 @@ declare const endpointDefinitionSchema: z.ZodObject<{
118
145
  full_load_append: "full_load_append";
119
146
  append: "append";
120
147
  }>;
148
+ type: z.ZodDefault<z.ZodEnum<{
149
+ s3: "s3";
150
+ minio: "minio";
151
+ }>>;
152
+ bucket: z.ZodString;
121
153
  basePath: z.ZodString;
154
+ region: z.ZodOptional<z.ZodString>;
155
+ endpoint: z.ZodOptional<z.ZodString>;
122
156
  }, z.core.$strip>]>>;
123
157
  }, z.core.$strip>;
124
158
  type EndpointDefinitionFormat = z.infer<typeof endpointDefinitionSchema>;
@@ -131,4 +165,4 @@ declare function findDuplicateFieldNames(fields: FieldDefinition[], path?: strin
131
165
  path: string[];
132
166
  }[];
133
167
  //#endregion
134
- export { ArrayItemDefinition, EndpointDefinitionFormat, FieldDefinition, FieldOptions, FieldValidation, LoadStrategy, MutationConfig, PrimitiveType, endpointDefinitionSchema, fieldDefinitionSchema, fieldNamePattern, fieldOptionsSchema, fieldValidationSchema, findDuplicateFieldNames, loadStrategies, metadataFieldPattern, mutationConfigSchema, mutationSchema, primitiveTypes };
168
+ export { ArrayItemDefinition, EndpointDefinitionFormat, FieldDefinition, FieldOptions, FieldValidation, LoadStrategy, MutationConfig, PrimitiveType, StorageType, endpointDefinitionSchema, fieldDefinitionSchema, fieldNamePattern, fieldOptionsSchema, fieldValidationSchema, findDuplicateFieldNames, loadStrategies, metadataFieldPattern, mutationConfigSchema, mutationSchema, primitiveTypes, storageTypes };
@@ -1 +1 @@
1
- import{z as e}from"zod";const t=/^[a-zA-Z_][a-zA-Z0-9_]{0,63}$/u,n=/^[a-zA-Z_][a-zA-Z0-9_]{0,127}$/u,r=[`full_load`,`full_load_append`,`append`],i=e.object({loadStrategy:e.enum(r),basePath:e.string().min(1)}),a=e.union([e.literal(!1),i]),o=[`String`,`Integer`,`Float`,`Boolean`,`Date`,`DateTime`],s=e.union([e.object({type:e.literal(`email`)}),e.object({type:e.literal(`url`)}),e.object({type:e.literal(`uuid`)}),e.object({type:e.literal(`min`),value:e.number()}),e.object({type:e.literal(`max`),value:e.number()}),e.object({type:e.literal(`regex`),pattern:e.string()})]),c=e.object({required:e.boolean().optional(),validations:e.array(s).optional()}),l=e.lazy(()=>e.discriminatedUnion(`type`,[e.object({name:e.string().regex(t),type:e.literal(`String`),options:c.optional()}),e.object({name:e.string().regex(t),type:e.literal(`Integer`),options:c.optional()}),e.object({name:e.string().regex(t),type:e.literal(`Float`),options:c.optional()}),e.object({name:e.string().regex(t),type:e.literal(`Boolean`),options:c.optional()}),e.object({name:e.string().regex(t),type:e.literal(`Date`),options:c.optional()}),e.object({name:e.string().regex(t),type:e.literal(`DateTime`),options:c.optional()}),e.object({name:e.string().regex(t),type:e.literal(`Object`),fields:e.array(l).min(1),options:c.optional()}),e.object({name:e.string().regex(t),type:e.literal(`Array`),items:e.union([e.object({type:e.enum(o)}),e.object({type:e.literal(`Object`),fields:e.array(l).min(1)})]),options:c.optional()})])),u=e.object({version:e.literal(`1.0`),tableName:e.string().regex(n),catalog:e.string().regex(n),schema:e.string().regex(n),fields:e.array(l),mutation:a.optional()});function d(e,t=[]){let n=[],r=new Set;for(let i of e)r.has(i.name)?n.push({name:i.name,path:t}):r.add(i.name),i.type===`Object`&&i.fields&&n.push(...d(i.fields,[...t,i.name])),i.type===`Array`&&i.items?.type===`Object`&&i.items.fields&&n.push(...d(i.items.fields,[...t,i.name,`items`]));return n}export{u as endpointDefinitionSchema,l as fieldDefinitionSchema,t as fieldNamePattern,c as fieldOptionsSchema,s as fieldValidationSchema,d as findDuplicateFieldNames,r as loadStrategies,n as metadataFieldPattern,i as mutationConfigSchema,a as mutationSchema,o as primitiveTypes};
1
+ import{z as e}from"zod";const t=/^[a-zA-Z_][a-zA-Z0-9_]{0,63}$/u,n=/^[a-zA-Z_][a-zA-Z0-9_]{0,127}$/u,r=[`full_load`,`full_load_append`,`append`],i=[`s3`,`minio`],a=e.object({loadStrategy:e.enum(r),type:e.enum(i).default(`s3`),bucket:e.string().min(1),basePath:e.string().min(1),region:e.string().optional(),endpoint:e.string().optional()}),o=e.union([e.literal(!1),a]),s=[`String`,`Integer`,`Float`,`Boolean`,`Date`,`DateTime`],c=e.union([e.object({type:e.literal(`email`)}),e.object({type:e.literal(`url`)}),e.object({type:e.literal(`uuid`)}),e.object({type:e.literal(`min`),value:e.number()}),e.object({type:e.literal(`max`),value:e.number()}),e.object({type:e.literal(`regex`),pattern:e.string()})]),l=e.object({required:e.boolean().optional(),validations:e.array(c).optional()}),u=e.lazy(()=>e.discriminatedUnion(`type`,[e.object({name:e.string().regex(t),type:e.literal(`String`),options:l.optional()}),e.object({name:e.string().regex(t),type:e.literal(`Integer`),options:l.optional()}),e.object({name:e.string().regex(t),type:e.literal(`Float`),options:l.optional()}),e.object({name:e.string().regex(t),type:e.literal(`Boolean`),options:l.optional()}),e.object({name:e.string().regex(t),type:e.literal(`Date`),options:l.optional()}),e.object({name:e.string().regex(t),type:e.literal(`DateTime`),options:l.optional()}),e.object({name:e.string().regex(t),type:e.literal(`Object`),fields:e.array(u).min(1),options:l.optional()}),e.object({name:e.string().regex(t),type:e.literal(`Array`),items:e.union([e.object({type:e.enum(s)}),e.object({type:e.literal(`Object`),fields:e.array(u).min(1)})]),options:l.optional()})])),d=e.object({version:e.literal(`1.0`),tableName:e.string().regex(n),catalog:e.string().regex(n),schema:e.string().regex(n),fields:e.array(u),mutation:o.optional()});function f(e,t=[]){let n=[],r=new Set;for(let i of e)r.has(i.name)?n.push({name:i.name,path:t}):r.add(i.name),i.type===`Object`&&i.fields&&n.push(...f(i.fields,[...t,i.name])),i.type===`Array`&&i.items?.type===`Object`&&i.items.fields&&n.push(...f(i.items.fields,[...t,i.name,`items`]));return n}export{d as endpointDefinitionSchema,u as fieldDefinitionSchema,t as fieldNamePattern,l as fieldOptionsSchema,c as fieldValidationSchema,f as findDuplicateFieldNames,r as loadStrategies,n as metadataFieldPattern,a as mutationConfigSchema,o as mutationSchema,s as primitiveTypes,i as storageTypes};
@@ -1 +1 @@
1
- import{isObject as e}from"@lakeql/helpers/object-helper";import{createRegExp as t,global as n,not as r}from"magic-regexp";function i(e){return{$schema:`https://json-schema.org/draft-07/schema#`,...s(e),additionalProperties:!1}}function a(e){let i=t(r.letter,[n]),a=e.toString().replace(i,``);switch(a){case`varchar`:return{type:`string`};case`decimal`:case`double`:case`float`:return{type:`number`};case`integer`:case`bigint`:return{type:`integer`};case`boolean`:return{type:`boolean`};case`timestamp`:return{format:`date-time`,type:`string`};case`date`:return{format:`date`,type:`string`};default:throw Error(`Type ${a.toString()} is unknown.`)}}function o(t){if(t.length>1)throw Error("We expect that an array has only one element ( e.g. a primitive like `varchar` or an object like `row()`.");if(Array.isArray(t[0]))throw TypeError(`We currently do not support 'array of array'. Feel free to raise an issue.`);if(typeof t[0]==`string`)return{items:a(t[0]),type:`array`};if(e(t[0]))return{items:s(t[0]),type:`array`};throw Error("Unexpected case in `json-generator.handleArray`")}function s(t){let n={additionalProperties:!1,properties:{},type:`object`};for(let[r,i]of Object.entries(t)){if(typeof i==`string`)try{n.properties[r]=a(i)}catch(e){console.log(e)}if(Array.isArray(i))try{n.properties[r]=o(i)}catch(e){console.log(e)}if(e(i))try{n.properties[r]=s(i)}catch(e){console.log(e)}}return n}function c(e){switch(e){case`String`:return{type:`string`};case`Integer`:return{type:`integer`};case`Float`:return{type:`number`};case`Boolean`:return{type:`boolean`};case`Date`:return{type:`string`,format:`date`};case`DateTime`:return{type:`string`,format:`date-time`};default:return{type:`string`}}}function l(e){return e.type===`Object`&&e.fields?{type:`object`,properties:d(e.fields),additionalProperties:!1}:c(e.type)}function u(e){switch(e.type){case`Object`:return{type:`object`,properties:d(e.fields??[]),additionalProperties:!1};case`Array`:return{type:`array`,items:e.items?l(e.items):{type:`string`}};default:return c(e.type)}}function d(e){let t={};for(let n of e)t[n.name]=u(n);return t}function f(e){return{$schema:`https://json-schema.org/draft-07/schema#`,type:`object`,properties:d(e),additionalProperties:!1}}export{i as generateJsonSchema,f as generateJsonSchemaFromFields};
1
+ import{isObject as e}from"@lakeql/helpers/object-helper";import{createRegExp as t,global as n,not as r}from"magic-regexp";function i(e){return{$schema:`https://json-schema.org/draft-07/schema#`,...s(e),additionalProperties:!1}}function a(e){let i=t(r.letter,[n]),a=e.toString().replace(i,``);switch(a){case`varchar`:return{type:`string`};case`decimal`:case`double`:case`float`:return{type:`number`};case`integer`:case`bigint`:return{type:`integer`};case`boolean`:return{type:`boolean`};case`timestamp`:return{format:`date-time`,type:`string`};case`date`:return{format:`date`,type:`string`};default:throw Error(`Type ${a.toString()} is unknown.`)}}function o(t){if(t.length>1)throw Error("We expect that an array has only one element ( e.g. a primitive like `varchar` or an object like `row()`.");if(Array.isArray(t[0]))throw TypeError(`We currently do not support 'array of array'. Feel free to raise an issue.`);if(typeof t[0]==`string`)return{items:a(t[0]),type:`array`};if(e(t[0]))return{items:s(t[0]),type:`array`};throw Error("Unexpected case in `json-generator.handleArray`")}function s(t){let n={additionalProperties:!1,properties:{},type:`object`};for(let[r,i]of Object.entries(t))typeof i==`string`&&(n.properties[r]=a(i)),Array.isArray(i)&&(n.properties[r]=o(i)),e(i)&&(n.properties[r]=s(i));return n}function c(e){switch(e){case`String`:return{type:`string`};case`Integer`:return{type:`integer`};case`Float`:return{type:`number`};case`Boolean`:return{type:`boolean`};case`Date`:return{type:`string`,format:`date`};case`DateTime`:return{type:`string`,format:`date-time`};default:return{type:`string`}}}function l(e){return e.type===`Object`&&e.fields?{type:`object`,properties:d(e.fields),additionalProperties:!1}:c(e.type)}function u(e){switch(e.type){case`Object`:return{type:`object`,properties:d(e.fields??[]),additionalProperties:!1};case`Array`:return{type:`array`,items:e.items?l(e.items):{type:`string`}};default:return c(e.type)}}function d(e){let t={};for(let n of e)t[n.name]=u(n);return t}function f(e){return{$schema:`https://json-schema.org/draft-07/schema#`,type:`object`,properties:d(e),additionalProperties:!1}}export{i as generateJsonSchema,f as generateJsonSchemaFromFields};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lakeql/schema-generator",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Generates GraphQL schemas, Hive table definitions, and JSON schemas from Trino metadata",
5
5
  "keywords": [
6
6
  "codegen",