@sprucelabs/schema 28.0.5 → 28.1.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.
@@ -1,6 +1,6 @@
1
1
  import { FieldDefinition } from './field.static.types';
2
- declare const supportedTypes: readonly ["image/png", "image/jpeg", "application/pdf", "*"];
3
- export declare type SupportedFileType = typeof supportedTypes[number];
2
+ export declare const supportedFileTypes: readonly ["image/png", "image/jpeg", "application/pdf", "*"];
3
+ export declare type SupportedFileType = typeof supportedFileTypes[number];
4
4
  export interface FileFieldValue {
5
5
  name: string;
6
6
  type?: SupportedFileType;
@@ -14,4 +14,3 @@ export declare type FileFieldDefinition = FieldDefinition<FileFieldValue> & {
14
14
  acceptableTypes: SupportedFileType[];
15
15
  };
16
16
  };
17
- export {};
@@ -1,7 +1,6 @@
1
- const supportedTypes = [
1
+ export const supportedFileTypes = [
2
2
  'image/png',
3
3
  'image/jpeg',
4
4
  'application/pdf',
5
5
  '*',
6
6
  ];
7
- export {};
@@ -1,6 +1,6 @@
1
1
  import { FieldDefinitions, FieldMap, FieldValueTypeGeneratorMap } from "./../.spruce/schemas/fields/fields.types";
2
2
  import { FieldError } from '../errors/options.types';
3
- import { Schema, SchemaValues, StaticSchemaEntity } from '../schemas.static.types';
3
+ import { Schema, SchemaFieldsByName, SchemaValues, StaticSchemaEntity } from '../schemas.static.types';
4
4
  import { Unpack, IsArray, IsRequired } from '../types/utilities.types';
5
5
  export interface SchemasById {
6
6
  [id: string]: Schema[];
@@ -26,6 +26,7 @@ export declare type ValidateOptions<F extends FieldDefinitions> = {
26
26
  schemasById?: SchemasById;
27
27
  } & Partial<F['options']>;
28
28
  export declare type FieldType = keyof FieldMap;
29
+ export declare type FieldName<F extends SchemaFieldsByName> = Extract<keyof F, string>;
29
30
  export declare type FieldDefinition<Value = any, DefaultValue = Value, ArrayValue = Value[], DefaultArrayValue = DefaultValue[]> = {
30
31
  type: FieldType;
31
32
  /** Default options are empty */
@@ -1,4 +1,3 @@
1
+ import { FieldName } from '../fields/field.static.types';
1
2
  import { SchemaFieldsByName } from '../schemas.static.types';
2
- declare type FieldName<F extends SchemaFieldsByName> = Extract<keyof F, string>;
3
3
  export default function dropFields<F extends SchemaFieldsByName, D extends FieldName<F>>(fields: F, dropFields: D[]): Omit<F, D>;
4
- export {};
@@ -1,7 +1,7 @@
1
+ import { FieldName } from '../fields/field.static.types';
1
2
  import { SchemaFieldsByName } from '../schemas.static.types';
2
- declare type FieldNames<F extends SchemaFieldsByName> = Extract<keyof F, string>;
3
3
  declare type PrivateFieldNames<F extends SchemaFieldsByName> = {
4
- [K in FieldNames<F>]: F[K]['isPrivate'] extends true ? K : never;
5
- }[FieldNames<F>];
4
+ [K in FieldName<F>]: F[K]['isPrivate'] extends true ? K : never;
5
+ }[FieldName<F>];
6
6
  export default function dropPrivateFields<F extends SchemaFieldsByName, D extends PrivateFieldNames<F>>(fields: F): Omit<F, D>;
7
7
  export {};
@@ -1,5 +1,5 @@
1
+ import { FieldName } from '../fields/field.static.types';
1
2
  import { SchemaFieldsByName } from '../schemas.static.types';
2
- declare type FieldName<F extends SchemaFieldsByName> = Extract<keyof F, string>;
3
3
  declare type MakeFieldsOptional<F extends SchemaFieldsByName> = {
4
4
  [K in keyof F]: {
5
5
  isRequired: false;
@@ -0,0 +1,3 @@
1
+ import { FieldName } from '../fields/field.static.types';
2
+ import { SchemaFieldsByName } from '../schemas.static.types';
3
+ export declare function pickFields<F extends SchemaFieldsByName, Name extends FieldName<F>>(fields: F, names: Name[]): Pick<F, Name>;
@@ -0,0 +1,7 @@
1
+ export function pickFields(fields, names) {
2
+ const final = {};
3
+ for (const name of names) {
4
+ final[name] = fields[name];
5
+ }
6
+ return final;
7
+ }
@@ -1,6 +1,6 @@
1
1
  import { FieldDefinition } from './field.static.types';
2
- declare const supportedTypes: readonly ["image/png", "image/jpeg", "application/pdf", "*"];
3
- export declare type SupportedFileType = typeof supportedTypes[number];
2
+ export declare const supportedFileTypes: readonly ["image/png", "image/jpeg", "application/pdf", "*"];
3
+ export declare type SupportedFileType = typeof supportedFileTypes[number];
4
4
  export interface FileFieldValue {
5
5
  name: string;
6
6
  type?: SupportedFileType;
@@ -14,4 +14,3 @@ export declare type FileFieldDefinition = FieldDefinition<FileFieldValue> & {
14
14
  acceptableTypes: SupportedFileType[];
15
15
  };
16
16
  };
17
- export {};
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const supportedTypes = [
3
+ exports.supportedFileTypes = void 0;
4
+ exports.supportedFileTypes = [
4
5
  'image/png',
5
6
  'image/jpeg',
6
7
  'application/pdf',
@@ -1,6 +1,6 @@
1
1
  import { FieldDefinitions, FieldMap, FieldValueTypeGeneratorMap } from "./../.spruce/schemas/fields/fields.types";
2
2
  import { FieldError } from '../errors/options.types';
3
- import { Schema, SchemaValues, StaticSchemaEntity } from '../schemas.static.types';
3
+ import { Schema, SchemaFieldsByName, SchemaValues, StaticSchemaEntity } from '../schemas.static.types';
4
4
  import { Unpack, IsArray, IsRequired } from '../types/utilities.types';
5
5
  export interface SchemasById {
6
6
  [id: string]: Schema[];
@@ -26,6 +26,7 @@ export declare type ValidateOptions<F extends FieldDefinitions> = {
26
26
  schemasById?: SchemasById;
27
27
  } & Partial<F['options']>;
28
28
  export declare type FieldType = keyof FieldMap;
29
+ export declare type FieldName<F extends SchemaFieldsByName> = Extract<keyof F, string>;
29
30
  export declare type FieldDefinition<Value = any, DefaultValue = Value, ArrayValue = Value[], DefaultArrayValue = DefaultValue[]> = {
30
31
  type: FieldType;
31
32
  /** Default options are empty */
@@ -1,4 +1,3 @@
1
+ import { FieldName } from '../fields/field.static.types';
1
2
  import { SchemaFieldsByName } from '../schemas.static.types';
2
- declare type FieldName<F extends SchemaFieldsByName> = Extract<keyof F, string>;
3
3
  export default function dropFields<F extends SchemaFieldsByName, D extends FieldName<F>>(fields: F, dropFields: D[]): Omit<F, D>;
4
- export {};
@@ -1,7 +1,7 @@
1
+ import { FieldName } from '../fields/field.static.types';
1
2
  import { SchemaFieldsByName } from '../schemas.static.types';
2
- declare type FieldNames<F extends SchemaFieldsByName> = Extract<keyof F, string>;
3
3
  declare type PrivateFieldNames<F extends SchemaFieldsByName> = {
4
- [K in FieldNames<F>]: F[K]['isPrivate'] extends true ? K : never;
5
- }[FieldNames<F>];
4
+ [K in FieldName<F>]: F[K]['isPrivate'] extends true ? K : never;
5
+ }[FieldName<F>];
6
6
  export default function dropPrivateFields<F extends SchemaFieldsByName, D extends PrivateFieldNames<F>>(fields: F): Omit<F, D>;
7
7
  export {};
@@ -1,5 +1,5 @@
1
+ import { FieldName } from '../fields/field.static.types';
1
2
  import { SchemaFieldsByName } from '../schemas.static.types';
2
- declare type FieldName<F extends SchemaFieldsByName> = Extract<keyof F, string>;
3
3
  declare type MakeFieldsOptional<F extends SchemaFieldsByName> = {
4
4
  [K in keyof F]: {
5
5
  isRequired: false;
@@ -0,0 +1,3 @@
1
+ import { FieldName } from '../fields/field.static.types';
2
+ import { SchemaFieldsByName } from '../schemas.static.types';
3
+ export declare function pickFields<F extends SchemaFieldsByName, Name extends FieldName<F>>(fields: F, names: Name[]): Pick<F, Name>;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pickFields = void 0;
4
+ function pickFields(fields, names) {
5
+ const final = {};
6
+ for (const name of names) {
7
+ final[name] = fields[name];
8
+ }
9
+ return final;
10
+ }
11
+ exports.pickFields = pickFields;
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "!build/__tests__",
9
9
  "esm"
10
10
  ],
11
- "version": "28.0.5",
11
+ "version": "28.1.0",
12
12
  "main": "./build/index.js",
13
13
  "types": "./build/index.d.ts",
14
14
  "module": "./build/esm/index.js",
@@ -77,7 +77,7 @@
77
77
  "@sprucelabs/jest-sheets-reporter": "^1.3.29",
78
78
  "@sprucelabs/resolve-path-aliases": "^1.1.14",
79
79
  "@sprucelabs/semantic-release": "^4.0.8",
80
- "@sprucelabs/test-utils": "^3.0.541",
80
+ "@sprucelabs/test-utils": "^3.0.542",
81
81
  "@types/lodash": "^4.14.182",
82
82
  "chokidar-cli": "^3.0.0",
83
83
  "concurrently": "^7.1.0",