@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.
Files changed (44) hide show
  1. package/dist/access-token-rejected.d.mts +10 -0
  2. package/dist/access-token-rejected.mjs +12 -0
  3. package/dist/admin-api.d.mts +45 -0
  4. package/dist/admin-api.mjs +103 -0
  5. package/dist/admin-bulk-query-registry.d.mts +26 -0
  6. package/dist/admin-bulk-query-registry.mjs +8 -0
  7. package/dist/admin-operation-registry.d.mts +11 -0
  8. package/dist/admin-operation-registry.mjs +8 -0
  9. package/dist/admin-query-failed.d.mts +11 -0
  10. package/dist/admin-query-failed.mjs +13 -0
  11. package/dist/bulk/bulk-operation-refused.d.mts +15 -0
  12. package/dist/bulk/bulk-operation-refused.mjs +18 -0
  13. package/dist/bulk/bulk-operations-finish.d.mts +13 -0
  14. package/dist/bulk/bulk-operations-finish.mjs +26 -0
  15. package/dist/bulk/bulk-result-failed.d.mts +10 -0
  16. package/dist/bulk/bulk-result-failed.mjs +12 -0
  17. package/dist/bulk/bulk-results.mjs +131 -0
  18. package/dist/bulk/bulk-transport.d.mts +33 -0
  19. package/dist/bulk/bulk-transport.mjs +118 -0
  20. package/dist/bulk/bulk-upload-failed.d.mts +11 -0
  21. package/dist/bulk/bulk-upload-failed.mjs +13 -0
  22. package/dist/bulk/read-only-shopify-bulk.d.mts +26 -0
  23. package/dist/bulk/read-only-shopify-bulk.mjs +23 -0
  24. package/dist/bulk/shopify-bulk.d.mts +47 -0
  25. package/dist/bulk/shopify-bulk.mjs +123 -0
  26. package/dist/bulk.d.mts +8 -0
  27. package/dist/bulk.mjs +7 -0
  28. package/dist/delegate-token-refused.d.mts +10 -0
  29. package/dist/delegate-token-refused.mjs +12 -0
  30. package/dist/delegate-token.d.mts +17 -0
  31. package/dist/delegate-token.mjs +45 -0
  32. package/dist/index.d.mts +12 -0
  33. package/dist/index.mjs +11 -0
  34. package/dist/mutation-refused.d.mts +10 -0
  35. package/dist/mutation-refused.mjs +12 -0
  36. package/dist/operations.d.mts +12 -0
  37. package/dist/operations.mjs +1 -0
  38. package/dist/read-only-admin.d.mts +49 -0
  39. package/dist/read-only-admin.mjs +60 -0
  40. package/dist/shopify-layer.d.mts +11 -0
  41. package/dist/shopify-layer.mjs +8 -0
  42. package/dist/testing.d.mts +29 -0
  43. package/dist/testing.mjs +52 -0
  44. package/package.json +35 -1
@@ -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
- {"name":"@unisian/shopify-admin","version":"0.0.0","description":"Placeholder; releases come from baoagency/unisian-next CI.","license":"MIT"}
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
+ }