@brytdesigns/shopify-utils 1.2.14 → 1.2.16

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,16 +1,32 @@
1
1
  import * as Effect from 'effect/Effect';
2
2
  import * as Schema from 'effect/Schema';
3
+ import * as ParseResult from 'effect/ParseResult';
3
4
  import { ID, Type, GID } from './schema.js';
4
5
 
5
6
  const format = ({
6
7
  id,
7
8
  type
8
9
  }) => Effect.gen(function* () {
9
- const actualId = yield* Schema.decode(ID)(id);
10
- const actualType = yield* Schema.decode(Type)(type);
10
+ const [actualId, actualType] = yield* Effect.all(
11
+ [Schema.decode(ID)(id), Schema.decode(Type)(type)],
12
+ {
13
+ concurrency: "unbounded"
14
+ }
15
+ );
11
16
  return `gid://shopify/${actualType}/${actualId}`;
12
17
  });
13
- const parse = (input) => Schema.decode(GID)(input);
18
+ const parse = (input) => Schema.decode(
19
+ Schema.transformOrFail(GID, ID, {
20
+ encode: (value, _, ast) => ParseResult.fail(
21
+ new ParseResult.Forbidden(
22
+ ast,
23
+ value,
24
+ "Encoding an ID to a GID is not allowed. Use the format function to convert IDs to GIDs."
25
+ )
26
+ ),
27
+ decode: (value) => ParseResult.succeed(`${value}`.split("/").pop())
28
+ })
29
+ )(input);
14
30
 
15
31
  export { format, parse };
16
32
  //# sourceMappingURL=data.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/effect/Resource/data.ts"],"names":[],"mappings":";;;;AAWO,MAAM,SAAS,CAA2C;AAAA,EAC/D,EAAA;AAAA,EACA;AACF,CAKE,KAAA,MAAA,CAAO,IAAI,aAAa;AACtB,EAAA,MAAM,WAAW,OAAO,MAAA,CAAO,MAAO,CAAA,EAAE,EAAE,EAAE,CAAA;AAC5C,EAAA,MAAM,aAAa,OAAO,MAAA,CAAO,MAAO,CAAA,IAAI,EAAE,IAAI,CAAA;AAClD,EAAO,OAAA,CAAA,cAAA,EAAiB,UAAU,CAAA,CAAA,EAAI,QAAQ,CAAA,CAAA;AAChD,CAAC;AAEI,MAAM,QAAQ,CACnB,KAAA,KAC6C,OAAO,MAAO,CAAA,GAAG,EAAE,KAAK","file":"data.js","sourcesContent":["import type { ParseError } from \"effect/ParseResult\";\n\nimport * as Effect from \"effect/Effect\";\nimport * as Schema from \"effect/Schema\";\nimport { ID, GID, Type } from \"./schema.js\";\n\ntype FormatOptions<T extends ID, R extends Type> = {\n id: T;\n type: R;\n};\n\nexport const format = <const T extends ID, const R extends Type>({\n id,\n type,\n}: FormatOptions<T, R>): Effect.Effect<\n `gid://shopify/${R}/${T}`,\n ParseError,\n never\n> =>\n Effect.gen(function* () {\n const actualId = yield* Schema.decode(ID)(id);\n const actualType = yield* Schema.decode(Type)(type);\n return `gid://shopify/${actualType}/${actualId}` as `gid://shopify/${R}/${T}`;\n });\n\nexport const parse = (\n input: string,\n): Effect.Effect<string, ParseError, never> => Schema.decode(GID)(input);\n"]}
1
+ {"version":3,"sources":["../../../src/effect/Resource/data.ts"],"names":[],"mappings":";;;;;AAYO,MAAM,SAAS,CAA2C;AAAA,EAC/D,EAAA;AAAA,EACA;AACF,CAKE,KAAA,MAAA,CAAO,IAAI,aAAa;AACtB,EAAA,MAAM,CAAC,QAAA,EAAU,UAAU,CAAA,GAAI,OAAO,MAAO,CAAA,GAAA;AAAA,IAC3C,CAAC,MAAA,CAAO,MAAO,CAAA,EAAE,CAAE,CAAA,EAAE,CAAG,EAAA,MAAA,CAAO,MAAO,CAAA,IAAI,CAAE,CAAA,IAAI,CAAC,CAAA;AAAA,IACjD;AAAA,MACE,WAAa,EAAA;AAAA;AACf,GACF;AACA,EAAO,OAAA,CAAA,cAAA,EAAiB,UAAU,CAAA,CAAA,EAAI,QAAQ,CAAA,CAAA;AAChD,CAAC;AAEU,MAAA,KAAA,GAAQ,CAAC,KAAA,KACpB,MAAO,CAAA,MAAA;AAAA,EACL,MAAA,CAAO,eAAgB,CAAA,GAAA,EAAK,EAAI,EAAA;AAAA,IAC9B,MAAQ,EAAA,CAAC,KAAO,EAAA,CAAA,EAAG,QACjB,WAAY,CAAA,IAAA;AAAA,MACV,IAAI,WAAY,CAAA,SAAA;AAAA,QACd,GAAA;AAAA,QACA,KAAA;AAAA,QACA;AAAA;AACF,KACF;AAAA,IACF,MAAQ,EAAA,CAAC,KAAU,KAAA,WAAA,CAAY,OAAQ,CAAA,CAAA,EAAG,KAAK,CAAA,CAAA,CAAG,KAAM,CAAA,GAAG,CAAE,CAAA,GAAA,EAAM;AAAA,GACpE;AACH,CAAA,CAAE,KAAK","file":"data.js","sourcesContent":["import type { ParseError } from \"effect/ParseResult\";\n\nimport * as Effect from \"effect/Effect\";\nimport * as Schema from \"effect/Schema\";\nimport * as ParseResult from \"effect/ParseResult\";\nimport { ID, GID, Type } from \"./schema.js\";\n\ntype FormatOptions<T extends ID, R extends Type> = {\n id: T;\n type: R;\n};\n\nexport const format = <const T extends ID, const R extends Type>({\n id,\n type,\n}: FormatOptions<T, R>): Effect.Effect<\n `gid://shopify/${R}/${T}`,\n ParseError,\n never\n> =>\n Effect.gen(function* () {\n const [actualId, actualType] = yield* Effect.all(\n [Schema.decode(ID)(id), Schema.decode(Type)(type)],\n {\n concurrency: \"unbounded\",\n },\n );\n return `gid://shopify/${actualType}/${actualId}` as `gid://shopify/${R}/${T}`;\n });\n\nexport const parse = (input: string) =>\n Schema.decode(\n Schema.transformOrFail(GID, ID, {\n encode: (value, _, ast) =>\n ParseResult.fail(\n new ParseResult.Forbidden(\n ast,\n value,\n \"Encoding an ID to a GID is not allowed. Use the format function to convert IDs to GIDs.\",\n ),\n ),\n decode: (value) => ParseResult.succeed(`${value}`.split(\"/\").pop()!),\n }),\n )(input);\n"]}
@@ -55,7 +55,7 @@ export type FormatOptions<T extends ID, R extends Type> = {
55
55
  type: R;
56
56
  };
57
57
  declare const format: <const T extends ID, const R extends Type>({ id, type, }: FormatOptions<T, R>) => Effect.Effect<`gid://shopify/${R}/${T}`, ParseError, never>;
58
- declare const parse: (input: string) => Effect.Effect<string, ParseError, never>;
58
+ declare const parse: (input: string) => Effect.Effect<string | number, ParseError, never>;
59
59
  export interface IShopifyRoutes {
60
60
  readonly account_addresses_url: string;
61
61
  readonly account_login_url: string;
@@ -1,16 +1,32 @@
1
1
  import * as Effect from 'effect/Effect';
2
2
  import * as Schema from 'effect/Schema';
3
+ import * as ParseResult from 'effect/ParseResult';
3
4
  import { ID, Type, GID } from './schema.js';
4
5
 
5
6
  const format = ({
6
7
  id,
7
8
  type
8
9
  }) => Effect.gen(function* () {
9
- const actualId = yield* Schema.decode(ID)(id);
10
- const actualType = yield* Schema.decode(Type)(type);
10
+ const [actualId, actualType] = yield* Effect.all(
11
+ [Schema.decode(ID)(id), Schema.decode(Type)(type)],
12
+ {
13
+ concurrency: "unbounded"
14
+ }
15
+ );
11
16
  return `gid://shopify/${actualType}/${actualId}`;
12
17
  });
13
- const parse = (input) => Schema.decode(GID)(input);
18
+ const parse = (input) => Schema.decode(
19
+ Schema.transformOrFail(GID, ID, {
20
+ encode: (value, _, ast) => ParseResult.fail(
21
+ new ParseResult.Forbidden(
22
+ ast,
23
+ value,
24
+ "Encoding an ID to a GID is not allowed. Use the format function to convert IDs to GIDs."
25
+ )
26
+ ),
27
+ decode: (value) => ParseResult.succeed(`${value}`.split("/").pop())
28
+ })
29
+ )(input);
14
30
 
15
31
  export { format, parse };
16
32
  //# sourceMappingURL=data.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/effect/Resource/data.ts"],"names":[],"mappings":";;;;AAWO,MAAM,SAAS,CAA2C;AAAA,EAC/D,EAAA;AAAA,EACA;AACF,CAKE,KAAA,MAAA,CAAO,IAAI,aAAa;AACtB,EAAA,MAAM,WAAW,OAAO,MAAA,CAAO,MAAO,CAAA,EAAE,EAAE,EAAE,CAAA;AAC5C,EAAA,MAAM,aAAa,OAAO,MAAA,CAAO,MAAO,CAAA,IAAI,EAAE,IAAI,CAAA;AAClD,EAAO,OAAA,CAAA,cAAA,EAAiB,UAAU,CAAA,CAAA,EAAI,QAAQ,CAAA,CAAA;AAChD,CAAC;AAEI,MAAM,QAAQ,CACnB,KAAA,KAC6C,OAAO,MAAO,CAAA,GAAG,EAAE,KAAK","file":"data.js","sourcesContent":["import type { ParseError } from \"effect/ParseResult\";\n\nimport * as Effect from \"effect/Effect\";\nimport * as Schema from \"effect/Schema\";\nimport { ID, GID, Type } from \"./schema.js\";\n\ntype FormatOptions<T extends ID, R extends Type> = {\n id: T;\n type: R;\n};\n\nexport const format = <const T extends ID, const R extends Type>({\n id,\n type,\n}: FormatOptions<T, R>): Effect.Effect<\n `gid://shopify/${R}/${T}`,\n ParseError,\n never\n> =>\n Effect.gen(function* () {\n const actualId = yield* Schema.decode(ID)(id);\n const actualType = yield* Schema.decode(Type)(type);\n return `gid://shopify/${actualType}/${actualId}` as `gid://shopify/${R}/${T}`;\n });\n\nexport const parse = (\n input: string,\n): Effect.Effect<string, ParseError, never> => Schema.decode(GID)(input);\n"]}
1
+ {"version":3,"sources":["../../../../src/effect/Resource/data.ts"],"names":[],"mappings":";;;;;AAYO,MAAM,SAAS,CAA2C;AAAA,EAC/D,EAAA;AAAA,EACA;AACF,CAKE,KAAA,MAAA,CAAO,IAAI,aAAa;AACtB,EAAA,MAAM,CAAC,QAAA,EAAU,UAAU,CAAA,GAAI,OAAO,MAAO,CAAA,GAAA;AAAA,IAC3C,CAAC,MAAA,CAAO,MAAO,CAAA,EAAE,CAAE,CAAA,EAAE,CAAG,EAAA,MAAA,CAAO,MAAO,CAAA,IAAI,CAAE,CAAA,IAAI,CAAC,CAAA;AAAA,IACjD;AAAA,MACE,WAAa,EAAA;AAAA;AACf,GACF;AACA,EAAO,OAAA,CAAA,cAAA,EAAiB,UAAU,CAAA,CAAA,EAAI,QAAQ,CAAA,CAAA;AAChD,CAAC;AAEU,MAAA,KAAA,GAAQ,CAAC,KAAA,KACpB,MAAO,CAAA,MAAA;AAAA,EACL,MAAA,CAAO,eAAgB,CAAA,GAAA,EAAK,EAAI,EAAA;AAAA,IAC9B,MAAQ,EAAA,CAAC,KAAO,EAAA,CAAA,EAAG,QACjB,WAAY,CAAA,IAAA;AAAA,MACV,IAAI,WAAY,CAAA,SAAA;AAAA,QACd,GAAA;AAAA,QACA,KAAA;AAAA,QACA;AAAA;AACF,KACF;AAAA,IACF,MAAQ,EAAA,CAAC,KAAU,KAAA,WAAA,CAAY,OAAQ,CAAA,CAAA,EAAG,KAAK,CAAA,CAAA,CAAG,KAAM,CAAA,GAAG,CAAE,CAAA,GAAA,EAAM;AAAA,GACpE;AACH,CAAA,CAAE,KAAK","file":"data.js","sourcesContent":["import type { ParseError } from \"effect/ParseResult\";\n\nimport * as Effect from \"effect/Effect\";\nimport * as Schema from \"effect/Schema\";\nimport * as ParseResult from \"effect/ParseResult\";\nimport { ID, GID, Type } from \"./schema.js\";\n\ntype FormatOptions<T extends ID, R extends Type> = {\n id: T;\n type: R;\n};\n\nexport const format = <const T extends ID, const R extends Type>({\n id,\n type,\n}: FormatOptions<T, R>): Effect.Effect<\n `gid://shopify/${R}/${T}`,\n ParseError,\n never\n> =>\n Effect.gen(function* () {\n const [actualId, actualType] = yield* Effect.all(\n [Schema.decode(ID)(id), Schema.decode(Type)(type)],\n {\n concurrency: \"unbounded\",\n },\n );\n return `gid://shopify/${actualType}/${actualId}` as `gid://shopify/${R}/${T}`;\n });\n\nexport const parse = (input: string) =>\n Schema.decode(\n Schema.transformOrFail(GID, ID, {\n encode: (value, _, ast) =>\n ParseResult.fail(\n new ParseResult.Forbidden(\n ast,\n value,\n \"Encoding an ID to a GID is not allowed. Use the format function to convert IDs to GIDs.\",\n ),\n ),\n decode: (value) => ParseResult.succeed(`${value}`.split(\"/\").pop()!),\n }),\n )(input);\n"]}
@@ -54,8 +54,8 @@ export type FormatOptions<T extends ID, R extends Type> = {
54
54
  type: R;
55
55
  };
56
56
  declare const format: <const T extends ID, const R extends Type>({ id, type, }: FormatOptions<T, R>) => Effect.Effect<`gid://shopify/${R}/${T}`, ParseError, never>;
57
- declare const parse: (input: string) => Effect.Effect<string, ParseError, never>;
58
- export declare const parseResource: (gid: Resource.GID) => string;
57
+ declare const parse: (input: string) => Effect.Effect<string | number, ParseError, never>;
58
+ export declare const parseResource: (gid: Resource.GID) => string | number;
59
59
  export type FormatResourceOptions<T extends Resource.ID, R extends Resource.Type> = {
60
60
  id: T;
61
61
  type: R;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/resources/index.ts"],"names":[],"mappings":";;;AAGa,MAAA,aAAA,GAAgB,CAAC,GAC5B,KAAA,MAAA,CAAO,QAAQ,QAAS,CAAA,KAAA,CAAM,GAAG,CAAC;AAOvB,MAAA,cAAA,GAAiB,CAI5B,OACG,KAAA,MAAA,CAAO,QAAQ,QAAS,CAAA,MAAA,CAAa,OAAO,CAAC","file":"index.js","sourcesContent":["import * as Effect from \"effect/Effect\";\nimport { Resource } from \"../effect\";\n\nexport const parseResource = (gid: Resource.GID) =>\n Effect.runSync(Resource.parse(gid));\n\ntype FormatResourceOptions<T extends Resource.ID, R extends Resource.Type> = {\n id: T;\n type: R;\n};\n\nexport const formatResource = <\n const T extends Resource.ID,\n const R extends Resource.Type,\n>(\n options: FormatResourceOptions<T, R>\n) => Effect.runSync(Resource.format<T, R>(options));\n\nexport type ID = Resource.ID;\nexport type GID = Resource.GID;\nexport type Type = Resource.Type;\n"]}
1
+ {"version":3,"sources":["../../../src/resources/index.ts"],"names":[],"mappings":";;;AAGa,MAAA,aAAA,GAAgB,CAAC,GAC5B,KAAA,MAAA,CAAO,QAAQ,QAAS,CAAA,KAAA,CAAM,GAAG,CAAC;AAOvB,MAAA,cAAA,GAAiB,CAI5B,OACG,KAAA,MAAA,CAAO,QAAQ,QAAS,CAAA,MAAA,CAAa,OAAO,CAAC","file":"index.js","sourcesContent":["import * as Effect from \"effect/Effect\";\nimport { Resource } from \"../effect\";\n\nexport const parseResource = (gid: Resource.GID) =>\n Effect.runSync(Resource.parse(gid));\n\ntype FormatResourceOptions<T extends Resource.ID, R extends Resource.Type> = {\n id: T;\n type: R;\n};\n\nexport const formatResource = <\n const T extends Resource.ID,\n const R extends Resource.Type,\n>(\n options: FormatResourceOptions<T, R>,\n) => Effect.runSync(Resource.format<T, R>(options));\n\nexport type ID = Resource.ID;\nexport type GID = Resource.GID;\nexport type Type = Resource.Type;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brytdesigns/shopify-utils",
3
- "version": "1.2.14",
3
+ "version": "1.2.16",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/main/index.js",