@unisian/shopify-admin 0.0.0 → 0.6.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.
- package/dist/access-token-rejected.d.mts +10 -0
- package/dist/access-token-rejected.mjs +12 -0
- package/dist/admin-api.d.mts +45 -0
- package/dist/admin-api.mjs +103 -0
- package/dist/admin-bulk-query-registry.d.mts +26 -0
- package/dist/admin-bulk-query-registry.mjs +8 -0
- package/dist/admin-operation-registry.d.mts +11 -0
- package/dist/admin-operation-registry.mjs +8 -0
- package/dist/admin-query-failed.d.mts +11 -0
- package/dist/admin-query-failed.mjs +13 -0
- package/dist/bulk/bulk-operation-refused.d.mts +15 -0
- package/dist/bulk/bulk-operation-refused.mjs +18 -0
- package/dist/bulk/bulk-operations-finish.d.mts +13 -0
- package/dist/bulk/bulk-operations-finish.mjs +26 -0
- package/dist/bulk/bulk-result-failed.d.mts +10 -0
- package/dist/bulk/bulk-result-failed.mjs +12 -0
- package/dist/bulk/bulk-results.mjs +131 -0
- package/dist/bulk/bulk-transport.d.mts +33 -0
- package/dist/bulk/bulk-transport.mjs +118 -0
- package/dist/bulk/bulk-upload-failed.d.mts +11 -0
- package/dist/bulk/bulk-upload-failed.mjs +13 -0
- package/dist/bulk/read-only-shopify-bulk.d.mts +26 -0
- package/dist/bulk/read-only-shopify-bulk.mjs +23 -0
- package/dist/bulk/shopify-bulk.d.mts +47 -0
- package/dist/bulk/shopify-bulk.mjs +123 -0
- package/dist/bulk.d.mts +8 -0
- package/dist/bulk.mjs +7 -0
- package/dist/delegate-token-refused.d.mts +10 -0
- package/dist/delegate-token-refused.mjs +12 -0
- package/dist/delegate-token.d.mts +17 -0
- package/dist/delegate-token.mjs +45 -0
- package/dist/index.d.mts +12 -0
- package/dist/index.mjs +11 -0
- package/dist/mutation-refused.d.mts +10 -0
- package/dist/mutation-refused.mjs +12 -0
- package/dist/operations.d.mts +12 -0
- package/dist/operations.mjs +1 -0
- package/dist/read-only-admin.d.mts +49 -0
- package/dist/read-only-admin.mjs +60 -0
- package/dist/shopify-layer.d.mts +11 -0
- package/dist/shopify-layer.mjs +8 -0
- package/dist/testing.d.mts +29 -0
- package/dist/testing.mjs +52 -0
- package/package.json +35 -1
package/dist/testing.mjs
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { AdminOperationRegistry } from "./admin-operation-registry.mjs";
|
|
2
|
+
import { ShopifyAdmin } from "./admin-api.mjs";
|
|
3
|
+
import { AdminBulkQueryRegistry } from "./admin-bulk-query-registry.mjs";
|
|
4
|
+
import { ReadOnlyShopifyAdmin } from "./read-only-admin.mjs";
|
|
5
|
+
import { ShopifyBulk } from "./bulk/shopify-bulk.mjs";
|
|
6
|
+
import { ReadOnlyShopifyBulk } from "./bulk/read-only-shopify-bulk.mjs";
|
|
7
|
+
import * as Schema from "effect/Schema";
|
|
8
|
+
import * as Layer from "effect/Layer";
|
|
9
|
+
import * as Redacted from "effect/Redacted";
|
|
10
|
+
import { FetchHttpClient } from "effect/http";
|
|
11
|
+
//#region src/testing.ts
|
|
12
|
+
const GraphqlBody = Schema.Struct({
|
|
13
|
+
query: Schema.String,
|
|
14
|
+
variables: Schema.optional(Schema.Json)
|
|
15
|
+
});
|
|
16
|
+
const decodeBody = Schema.decodeUnknownSync(Schema.fromJsonString(GraphqlBody));
|
|
17
|
+
const stubApiVersion = "2026-10";
|
|
18
|
+
const adminStub = (shop, operations, answers, bulk = {}) => {
|
|
19
|
+
const sent = [];
|
|
20
|
+
const fetch = async (input, init) => {
|
|
21
|
+
const request = new Request(input, init);
|
|
22
|
+
if (!new URL(request.url).pathname.startsWith("/admin/api/")) {
|
|
23
|
+
const file = bulk.files?.[request.url];
|
|
24
|
+
return file === void 0 ? new Response("no such file", { status: 404 }) : await file(request);
|
|
25
|
+
}
|
|
26
|
+
const body = decodeBody(await request.text());
|
|
27
|
+
const name = /^(?:query|mutation) (?<name>\w+)/u.exec(body.query)?.groups?.name ?? "";
|
|
28
|
+
const answer = answers[name];
|
|
29
|
+
sent.push({
|
|
30
|
+
name,
|
|
31
|
+
shop: new URL(request.url).hostname,
|
|
32
|
+
variables: body.variables
|
|
33
|
+
});
|
|
34
|
+
return answer === void 0 ? new Response(`no answer for ${name}`, { status: 500 }) : Response.json({ data: answer(body.variables) });
|
|
35
|
+
};
|
|
36
|
+
const credential = {
|
|
37
|
+
accessToken: Redacted.make("shpat_test"),
|
|
38
|
+
shop
|
|
39
|
+
};
|
|
40
|
+
const services = Layer.mergeAll(AdminOperationRegistry.layer(operations), AdminBulkQueryRegistry.layer(bulk.bulkQueries ?? {}), FetchHttpClient.layer.pipe(Layer.provide(Layer.succeed(FetchHttpClient.Fetch, fetch))));
|
|
41
|
+
const layer = ShopifyAdmin.layerForToken(credential, stubApiVersion).pipe(Layer.provide(services));
|
|
42
|
+
const readOnlyLayer = ReadOnlyShopifyAdmin.layerForToken(credential, stubApiVersion).pipe(Layer.provide(services));
|
|
43
|
+
return {
|
|
44
|
+
bulkLayer: ShopifyBulk.layerForToken(credential, stubApiVersion).pipe(Layer.provide(services)),
|
|
45
|
+
layer,
|
|
46
|
+
readOnlyBulkLayer: ReadOnlyShopifyBulk.layerForToken(credential, stubApiVersion).pipe(Layer.provide(services)),
|
|
47
|
+
readOnlyLayer,
|
|
48
|
+
sent
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
//#endregion
|
|
52
|
+
export { adminStub };
|
package/package.json
CHANGED
|
@@ -1 +1,35 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"name": "@unisian/shopify-admin",
|
|
3
|
+
"version": "0.6.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/baoagency/unisian-next.git",
|
|
8
|
+
"directory": "packages/shopify-admin"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"type": "module",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": "./dist/index.mjs",
|
|
16
|
+
"./bulk": "./dist/bulk.mjs",
|
|
17
|
+
"./operations": "./dist/operations.mjs",
|
|
18
|
+
"./testing": "./dist/testing.mjs"
|
|
19
|
+
},
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"effect": "4.0.6",
|
|
25
|
+
"@unisian/shopify-sessions": "0.6.0",
|
|
26
|
+
"@unisian/effect-observability": "0.6.0",
|
|
27
|
+
"@unisian/shopify-auth": "0.6.0"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"effect": "^4.0.2",
|
|
31
|
+
"@unisian/shopify-auth": "0.6.0",
|
|
32
|
+
"@unisian/shopify-sessions": "0.6.0"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {}
|
|
35
|
+
}
|