@sprucelabs/schema 32.3.7 → 32.3.8

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.
@@ -14,7 +14,7 @@ class RawField extends AbstractField {
14
14
  resolvedType = `${arrayNotation}${goType}`;
15
15
  }
16
16
  else {
17
- resolvedType = `${arrayNotation}${valueType}`;
17
+ resolvedType = `${valueType}${arrayNotation}`;
18
18
  }
19
19
  return {
20
20
  valueType: resolvedType,
@@ -28,7 +28,6 @@ export interface StaticSchemaEntity<S extends Schema> extends SchemaEntity {
28
28
  validate(options?: SchemaValidateOptions<S>): void;
29
29
  isValid(options?: SchemaValidateOptions<S>): boolean;
30
30
  }
31
- /** @ts-ignore */
32
31
  export type SchemaValues<S extends Schema, CreateEntityInstances extends boolean = false, IncludePrivateFields extends boolean = true, ShouldIncludeNullAndUndefinedFields extends boolean = false, F extends SchemaFieldNames<S> = SchemaFieldNames<S>, PF extends SchemaPublicFieldNames<S> = SchemaPublicFieldNames<S>> = IsDynamicSchema<S> extends true ? DynamicSchemaAllValues<S> : IncludePrivateFields extends false ? ShouldIncludeNullAndUndefinedFields extends true ? Pick<SchemaAllValues<S, CreateEntityInstances>, PF> : Pick<SchemaStaticValues<S, CreateEntityInstances>, PF> : ShouldIncludeNullAndUndefinedFields extends true ? Pick<SchemaAllValues<S, CreateEntityInstances>, F> : Pick<SchemaStaticValues<S, CreateEntityInstances>, F>;
33
32
  export interface DynamicSchemaEntityByName<ISchema extends Schema, OurField extends Field<any> = ISchema['dynamicFieldSignature'] extends FieldDefinitions ? FieldMap[ISchema['dynamicFieldSignature']['type']] : any> extends SchemaEntity, Omit<StaticSchemaEntity<ISchema>, 'get' | 'set' | 'getValues' | 'setValues' | 'getNamedFields' | 'schemaId' | 'namespace' | 'name' | 'version' | 'description'> {
34
33
  get<F extends string, CreateEntityInstances extends boolean = true>(fieldName: F, options?: DynamicSchemaNormalizeOptions<CreateEntityInstances>): FieldDefinitionValueType<OurField, CreateEntityInstances>;
@@ -48,7 +47,7 @@ export interface Schema {
48
47
  description?: string;
49
48
  importsWhenLocal?: string[];
50
49
  importsWhenRemote?: string[];
51
- moduleToImportFromWhenRemote?: string;
50
+ moduleToImportFromWhenRemote?: string | SchemaImport;
52
51
  typeSuffix?: string;
53
52
  dynamicFieldSignature?: FieldDefinitions & {
54
53
  keyName: string;
@@ -56,6 +55,11 @@ export interface Schema {
56
55
  };
57
56
  fields?: SchemaFieldsByName;
58
57
  }
58
+ export type SchemaSupportedLanguages = 'ts' | 'go';
59
+ export interface SchemaImport {
60
+ language: SchemaSupportedLanguages;
61
+ module: string;
62
+ }
59
63
  export interface SchemaFieldValueUnion<V extends Record<string, any> = Record<string, any>, Id extends string = string, Version extends string | undefined = undefined> {
60
64
  id: Id;
61
65
  version?: Version;
@@ -1,5 +1,5 @@
1
1
  import { FieldDefinitions } from '../fields';
2
- import { Schema } from '../schemas.static.types';
2
+ import { Schema, SchemaSupportedLanguages } from '../schemas.static.types';
3
3
  export interface FieldTemplateDetails {
4
4
  /** The type literal of value (string, number) */
5
5
  valueType: string;
@@ -15,7 +15,7 @@ export declare enum TemplateRenderAs {
15
15
  /** We are rendering as the schema's field type (Schema) */
16
16
  SchemaType = "schemaType"
17
17
  }
18
- export type TemplateLanguage = 'ts' | 'go';
18
+ export type TemplateLanguage = SchemaSupportedLanguages;
19
19
  /** The shape of options passed to AbstractField.generateTemplateDetails(options) */
20
20
  export interface FieldTemplateDetailOptions<T extends FieldDefinitions> {
21
21
  /** The language we're generating to, only TS for now */
@@ -19,7 +19,7 @@ class RawField extends AbstractField_1.default {
19
19
  resolvedType = `${arrayNotation}${goType}`;
20
20
  }
21
21
  else {
22
- resolvedType = `${arrayNotation}${valueType}`;
22
+ resolvedType = `${valueType}${arrayNotation}`;
23
23
  }
24
24
  return {
25
25
  valueType: resolvedType,
@@ -28,7 +28,6 @@ export interface StaticSchemaEntity<S extends Schema> extends SchemaEntity {
28
28
  validate(options?: SchemaValidateOptions<S>): void;
29
29
  isValid(options?: SchemaValidateOptions<S>): boolean;
30
30
  }
31
- /** @ts-ignore */
32
31
  export type SchemaValues<S extends Schema, CreateEntityInstances extends boolean = false, IncludePrivateFields extends boolean = true, ShouldIncludeNullAndUndefinedFields extends boolean = false, F extends SchemaFieldNames<S> = SchemaFieldNames<S>, PF extends SchemaPublicFieldNames<S> = SchemaPublicFieldNames<S>> = IsDynamicSchema<S> extends true ? DynamicSchemaAllValues<S> : IncludePrivateFields extends false ? ShouldIncludeNullAndUndefinedFields extends true ? Pick<SchemaAllValues<S, CreateEntityInstances>, PF> : Pick<SchemaStaticValues<S, CreateEntityInstances>, PF> : ShouldIncludeNullAndUndefinedFields extends true ? Pick<SchemaAllValues<S, CreateEntityInstances>, F> : Pick<SchemaStaticValues<S, CreateEntityInstances>, F>;
33
32
  export interface DynamicSchemaEntityByName<ISchema extends Schema, OurField extends Field<any> = ISchema['dynamicFieldSignature'] extends FieldDefinitions ? FieldMap[ISchema['dynamicFieldSignature']['type']] : any> extends SchemaEntity, Omit<StaticSchemaEntity<ISchema>, 'get' | 'set' | 'getValues' | 'setValues' | 'getNamedFields' | 'schemaId' | 'namespace' | 'name' | 'version' | 'description'> {
34
33
  get<F extends string, CreateEntityInstances extends boolean = true>(fieldName: F, options?: DynamicSchemaNormalizeOptions<CreateEntityInstances>): FieldDefinitionValueType<OurField, CreateEntityInstances>;
@@ -48,7 +47,7 @@ export interface Schema {
48
47
  description?: string;
49
48
  importsWhenLocal?: string[];
50
49
  importsWhenRemote?: string[];
51
- moduleToImportFromWhenRemote?: string;
50
+ moduleToImportFromWhenRemote?: string | SchemaImport;
52
51
  typeSuffix?: string;
53
52
  dynamicFieldSignature?: FieldDefinitions & {
54
53
  keyName: string;
@@ -56,6 +55,11 @@ export interface Schema {
56
55
  };
57
56
  fields?: SchemaFieldsByName;
58
57
  }
58
+ export type SchemaSupportedLanguages = 'ts' | 'go';
59
+ export interface SchemaImport {
60
+ language: SchemaSupportedLanguages;
61
+ module: string;
62
+ }
59
63
  export interface SchemaFieldValueUnion<V extends Record<string, any> = Record<string, any>, Id extends string = string, Version extends string | undefined = undefined> {
60
64
  id: Id;
61
65
  version?: Version;
@@ -1,5 +1,5 @@
1
1
  import { FieldDefinitions } from '../fields';
2
- import { Schema } from '../schemas.static.types';
2
+ import { Schema, SchemaSupportedLanguages } from '../schemas.static.types';
3
3
  export interface FieldTemplateDetails {
4
4
  /** The type literal of value (string, number) */
5
5
  valueType: string;
@@ -15,7 +15,7 @@ export declare enum TemplateRenderAs {
15
15
  /** We are rendering as the schema's field type (Schema) */
16
16
  SchemaType = "schemaType"
17
17
  }
18
- export type TemplateLanguage = 'ts' | 'go';
18
+ export type TemplateLanguage = SchemaSupportedLanguages;
19
19
  /** The shape of options passed to AbstractField.generateTemplateDetails(options) */
20
20
  export interface FieldTemplateDetailOptions<T extends FieldDefinitions> {
21
21
  /** The language we're generating to, only TS for now */
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "!build/__tests__",
9
9
  "esm"
10
10
  ],
11
- "version": "32.3.7",
11
+ "version": "32.3.8",
12
12
  "main": "./build/index.js",
13
13
  "types": "./build/index.d.ts",
14
14
  "module": "./build/esm/index.js",