@bessemer/cornerstone 0.5.76 → 0.5.78

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,9 +1,10 @@
1
1
  import { JoinPath, NominalType, ToStringArray } from '@bessemer/cornerstone/types';
2
2
  import Zod from 'zod';
3
+ import { ObjectPath } from '@bessemer/cornerstone/object/object-path';
3
4
  export type TypePathType = string;
4
5
  export type TypePath<T extends TypePathType = TypePathType> = NominalType<Array<string>, ['TypePath', T]>;
5
6
  export declare const of: <T extends Array<string | number>>(value: T) => TypePath<JoinPath<ToStringArray<T>>>;
6
7
  export declare const fromString: <T extends TypePathType>(path: T) => TypePath<T>;
7
8
  export declare const Schema: Zod.ZodPipe<Zod.ZodUnion<readonly [Zod.ZodArray<Zod.ZodString>, Zod.ZodString]>, Zod.ZodTransform<TypePath<string>, string | string[]>>;
8
- export declare const matches: (evaluatingPath: TypePath, targetPath: TypePath) => boolean;
9
+ export declare const matches: (evaluatingPath: TypePath, targetPath: TypePath | ObjectPath) => boolean;
9
10
  //# sourceMappingURL=type-path.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"type-path.d.ts","sourceRoot":"","sources":["../../src/object/type-path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAElF,OAAO,GAAG,MAAM,KAAK,CAAA;AAIrB,MAAM,MAAM,YAAY,GAAG,MAAM,CAAA;AACjC,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,YAAY,GAAG,YAAY,IAAI,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAA;AAEzG,eAAO,MAAM,EAAE,GAAI,CAAC,SAAS,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,OAAO,CAAC,KAAG,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAElG,CAAA;AAID,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,YAAY,EAAE,MAAM,CAAC,KAAG,QAAQ,CAAC,CAAC,CAGtE,CAAA;AAED,eAAO,MAAM,MAAM,yIAMjB,CAAA;AAEF,eAAO,MAAM,OAAO,GAAI,gBAAgB,QAAQ,EAAE,YAAY,QAAQ,KAAG,OAuBxE,CAAA"}
1
+ {"version":3,"file":"type-path.d.ts","sourceRoot":"","sources":["../../src/object/type-path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAElF,OAAO,GAAG,MAAM,KAAK,CAAA;AACrB,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAA;AAIrE,MAAM,MAAM,YAAY,GAAG,MAAM,CAAA;AACjC,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,YAAY,GAAG,YAAY,IAAI,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAA;AAEzG,eAAO,MAAM,EAAE,GAAI,CAAC,SAAS,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,OAAO,CAAC,KAAG,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAElG,CAAA;AAID,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,YAAY,EAAE,MAAM,CAAC,KAAG,QAAQ,CAAC,CAAC,CAGtE,CAAA;AAED,eAAO,MAAM,MAAM,yIAMjB,CAAA;AAEF,eAAO,MAAM,OAAO,GAAI,gBAAgB,QAAQ,EAAE,YAAY,QAAQ,GAAG,UAAU,KAAG,OAuBrF,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/object/type-path.ts"],"sourcesContent":["import { JoinPath, NominalType, ToStringArray } from '@bessemer/cornerstone/types'\nimport { assert } from '@bessemer/cornerstone/assertion'\nimport Zod from 'zod'\n\n// see https://github.com/sinclairnick/jsonpath-ts for type inference examples!\n\nexport type TypePathType = string\nexport type TypePath<T extends TypePathType = TypePathType> = NominalType<Array<string>, ['TypePath', T]>\n\nexport const of = <T extends Array<string | number>>(value: T): TypePath<JoinPath<ToStringArray<T>>> => {\n return value.map((it) => `${it}`) as TypePath<JoinPath<ToStringArray<T>>>\n}\n\nconst TypePathRegex = /^[a-zA-Z_$][a-zA-Z0-9_$]*(?:\\.[a-zA-Z_$][a-zA-Z0-9_$]*|\\[\\d+]|\\[\\*])*$/\n\nexport const fromString = <T extends TypePathType>(path: T): TypePath<T> => {\n assert(TypePathRegex.test(path), () => `Unable to parse ObjectPath from string: ${path}`)\n return of(path.split('.')) as TypePath<T>\n}\n\nexport const Schema = Zod.union([Zod.array(Zod.string()), Zod.string()]).transform((it) => {\n if (Array.isArray(it)) {\n return of(it)\n } else {\n return fromString(it)\n }\n})\n\nexport const matches = (evaluatingPath: TypePath, targetPath: TypePath): boolean => {\n if (targetPath.length !== evaluatingPath.length) {\n return false\n }\n\n for (let i = 0; i < targetPath.length; i++) {\n const evaluatingSegment = evaluatingPath[i]\n const targetSegment = targetPath[i]\n\n if (evaluatingSegment === '*') {\n continue\n }\n\n if (targetSegment === '*') {\n return false\n }\n\n if (targetSegment !== evaluatingSegment) {\n return false\n }\n }\n\n return true\n}\n"],"mappings":";AACA,SAAS,cAAc;AACvB,OAAO,SAAS;AAOT,IAAM,KAAK,CAAmC,UAAmD;AACtG,SAAO,MAAM,IAAI,CAAC,OAAO,GAAG,EAAE,EAAE;AAClC;AAEA,IAAM,gBAAgB;AAEf,IAAM,aAAa,CAAyB,SAAyB;AAC1E,SAAO,cAAc,KAAK,IAAI,GAAG,MAAM,2CAA2C,IAAI,EAAE;AACxF,SAAO,GAAG,KAAK,MAAM,GAAG,CAAC;AAC3B;AAEO,IAAM,SAAS,IAAI,MAAM,CAAC,IAAI,MAAM,IAAI,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,UAAU,CAAC,OAAO;AACzF,MAAI,MAAM,QAAQ,EAAE,GAAG;AACrB,WAAO,GAAG,EAAE;AAAA,EACd,OAAO;AACL,WAAO,WAAW,EAAE;AAAA,EACtB;AACF,CAAC;AAEM,IAAM,UAAU,CAAC,gBAA0B,eAAkC;AAClF,MAAI,WAAW,WAAW,eAAe,QAAQ;AAC/C,WAAO;AAAA,EACT;AAEA,WAAS,IAAI,GAAG,IAAI,WAAW,QAAQ,KAAK;AAC1C,UAAM,oBAAoB,eAAe,CAAC;AAC1C,UAAM,gBAAgB,WAAW,CAAC;AAElC,QAAI,sBAAsB,KAAK;AAC7B;AAAA,IACF;AAEA,QAAI,kBAAkB,KAAK;AACzB,aAAO;AAAA,IACT;AAEA,QAAI,kBAAkB,mBAAmB;AACvC,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/object/type-path.ts"],"sourcesContent":["import { JoinPath, NominalType, ToStringArray } from '@bessemer/cornerstone/types'\nimport { assert } from '@bessemer/cornerstone/assertion'\nimport Zod from 'zod'\nimport { ObjectPath } from '@bessemer/cornerstone/object/object-path'\n\n// see https://github.com/sinclairnick/jsonpath-ts for type inference examples!\n\nexport type TypePathType = string\nexport type TypePath<T extends TypePathType = TypePathType> = NominalType<Array<string>, ['TypePath', T]>\n\nexport const of = <T extends Array<string | number>>(value: T): TypePath<JoinPath<ToStringArray<T>>> => {\n return value.map((it) => `${it}`) as TypePath<JoinPath<ToStringArray<T>>>\n}\n\nconst TypePathRegex = /^[a-zA-Z_$][a-zA-Z0-9_$]*(?:\\.[a-zA-Z_$][a-zA-Z0-9_$]*|\\[\\d+]|\\[\\*])*$/\n\nexport const fromString = <T extends TypePathType>(path: T): TypePath<T> => {\n assert(TypePathRegex.test(path), () => `Unable to parse ObjectPath from string: ${path}`)\n return of(path.split('.')) as TypePath<T>\n}\n\nexport const Schema = Zod.union([Zod.array(Zod.string()), Zod.string()]).transform((it) => {\n if (Array.isArray(it)) {\n return of(it)\n } else {\n return fromString(it)\n }\n})\n\nexport const matches = (evaluatingPath: TypePath, targetPath: TypePath | ObjectPath): boolean => {\n if (targetPath.length !== evaluatingPath.length) {\n return false\n }\n\n for (let i = 0; i < targetPath.length; i++) {\n const evaluatingSegment = evaluatingPath[i]\n const targetSegment = targetPath[i]\n\n if (evaluatingSegment === '*') {\n continue\n }\n\n if (targetSegment === '*') {\n return false\n }\n\n if (targetSegment !== evaluatingSegment) {\n return false\n }\n }\n\n return true\n}\n"],"mappings":";AACA,SAAS,cAAc;AACvB,OAAO,SAAS;AAQT,IAAM,KAAK,CAAmC,UAAmD;AACtG,SAAO,MAAM,IAAI,CAAC,OAAO,GAAG,EAAE,EAAE;AAClC;AAEA,IAAM,gBAAgB;AAEf,IAAM,aAAa,CAAyB,SAAyB;AAC1E,SAAO,cAAc,KAAK,IAAI,GAAG,MAAM,2CAA2C,IAAI,EAAE;AACxF,SAAO,GAAG,KAAK,MAAM,GAAG,CAAC;AAC3B;AAEO,IAAM,SAAS,IAAI,MAAM,CAAC,IAAI,MAAM,IAAI,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,UAAU,CAAC,OAAO;AACzF,MAAI,MAAM,QAAQ,EAAE,GAAG;AACrB,WAAO,GAAG,EAAE;AAAA,EACd,OAAO;AACL,WAAO,WAAW,EAAE;AAAA,EACtB;AACF,CAAC;AAEM,IAAM,UAAU,CAAC,gBAA0B,eAA+C;AAC/F,MAAI,WAAW,WAAW,eAAe,QAAQ;AAC/C,WAAO;AAAA,EACT;AAEA,WAAS,IAAI,GAAG,IAAI,WAAW,QAAQ,KAAK;AAC1C,UAAM,oBAAoB,eAAe,CAAC;AAC1C,UAAM,gBAAgB,WAAW,CAAC;AAElC,QAAI,sBAAsB,KAAK;AAC7B;AAAA,IACF;AAEA,QAAI,kBAAkB,KAAK;AACzB,aAAO;AAAA,IACT;AAEA,QAAI,kBAAkB,mBAAmB;AACvC,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bessemer/cornerstone",
3
3
  "type": "module",
4
- "version": "0.5.76",
4
+ "version": "0.5.78",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "sideEffects": false,
@@ -33,6 +33,7 @@
33
33
  "zod": "4.0.15"
34
34
  },
35
35
  "devDependencies": {
36
+ "expect-type": "1.2.2",
36
37
  "pino-pretty": "13.0.0"
37
38
  },
38
39
  "files": [