@brytdesigns/shopify-utils 1.2.13 → 1.2.15
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*
|
|
10
|
-
|
|
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(
|
|
18
|
+
const parse = (input) => Schema.decode(
|
|
19
|
+
Schema.transformOrFail(ID, GID, {
|
|
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":"
|
|
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,EAAA,EAAI,GAAK,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(ID, GID, {\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"]}
|
|
@@ -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*
|
|
10
|
-
|
|
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(
|
|
18
|
+
const parse = (input) => Schema.decode(
|
|
19
|
+
Schema.transformOrFail(ID, GID, {
|
|
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":"
|
|
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,EAAA,EAAI,GAAK,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(ID, GID, {\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"]}
|
|
@@ -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
|
|
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.
|
|
3
|
+
"version": "1.2.15",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/main/index.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"author": "",
|
|
23
23
|
"license": "ISC",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"effect": "3.
|
|
25
|
+
"effect": "3.16.13"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"dts-bundle-generator": "^9.5.1",
|