@sixtyninecommerce/admin 0.1.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/README.md +147 -0
- package/dist/api-tokens/index.d.ts +29 -0
- package/dist/api-tokens/index.js +90 -0
- package/dist/auth/index.d.ts +61 -0
- package/dist/auth/index.js +162 -0
- package/dist/auth/queries.d.ts +11 -0
- package/dist/auth/queries.js +49 -0
- package/dist/client.d.ts +83 -0
- package/dist/client.js +236 -0
- package/dist/content/forms.d.ts +133 -0
- package/dist/content/forms.js +65 -0
- package/dist/errors.d.ts +10 -0
- package/dist/errors.js +17 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +21 -0
- package/dist/platform/guard.d.ts +11 -0
- package/dist/platform/guard.js +20 -0
- package/dist/seo/redirects.d.ts +27 -0
- package/dist/seo/redirects.js +37 -0
- package/dist/tenant/channels.d.ts +6 -0
- package/dist/tenant/channels.js +7 -0
- package/dist/types.d.ts +118 -0
- package/dist/types.js +1 -0
- package/package.json +52 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import type { ChannelInfo, TenantContext, TenantScope } from '@sixtyninecommerce/core';
|
|
2
|
+
/** Per-call options every admin method accepts (spec §9.2). */
|
|
3
|
+
export interface Call {
|
|
4
|
+
/**
|
|
5
|
+
* Sent as `Idempotency-Key` on a REST write, and ignored on a GraphQL one —
|
|
6
|
+
* the Admin API has no header for it, so an `apiTokens.*` write is never
|
|
7
|
+
* deduplicated and a repeat is a second write.
|
|
8
|
+
*
|
|
9
|
+
* On REST, two of this SDK's writes are deduplicated by the service itself:
|
|
10
|
+
* `content.forms.upsertBySlug` (`PUT /forms/by-slug/:slug`) and
|
|
11
|
+
* `seo.redirects.create` (`POST /redirects`). Repeating one under the same
|
|
12
|
+
* key replays the first response instead of running it again; sending the
|
|
13
|
+
* same key with a DIFFERENT body is refused with 409. Everything else
|
|
14
|
+
* records the key on the wire and acts on nothing.
|
|
15
|
+
*
|
|
16
|
+
* Use a fresh key per intended write — a UUIDv7 is ideal — and reuse it only
|
|
17
|
+
* when retrying that same write. This SDK never retries a write on its own,
|
|
18
|
+
* so a repeat is always yours to send.
|
|
19
|
+
*/
|
|
20
|
+
idempotencyKey?: string;
|
|
21
|
+
tenant?: Partial<TenantContext>;
|
|
22
|
+
signal?: AbortSignal;
|
|
23
|
+
}
|
|
24
|
+
/** Options for a list method. `after` is the cursor from the previous page. */
|
|
25
|
+
export interface ListOptions extends Call {
|
|
26
|
+
after?: string;
|
|
27
|
+
limit?: number;
|
|
28
|
+
}
|
|
29
|
+
/** The signed-in principal, as the Admin API reports it. */
|
|
30
|
+
export interface Me {
|
|
31
|
+
id: string;
|
|
32
|
+
identifier: string;
|
|
33
|
+
channels: Array<{
|
|
34
|
+
id: string;
|
|
35
|
+
code: string;
|
|
36
|
+
token: string;
|
|
37
|
+
permissions: string[];
|
|
38
|
+
}>;
|
|
39
|
+
administrator: {
|
|
40
|
+
id: string;
|
|
41
|
+
firstName: string;
|
|
42
|
+
lastName: string;
|
|
43
|
+
emailAddress: string;
|
|
44
|
+
} | null;
|
|
45
|
+
}
|
|
46
|
+
/** What `auth.whoami()` reports about the calling credential. */
|
|
47
|
+
export interface WhoAmI {
|
|
48
|
+
/** `api_token` never discloses the hidden administrator behind the token. */
|
|
49
|
+
kind: 'api_token' | 'user';
|
|
50
|
+
/** Present only for a token principal; null for a human session. */
|
|
51
|
+
token: {
|
|
52
|
+
id: string;
|
|
53
|
+
name: string;
|
|
54
|
+
tokenPrefix: string;
|
|
55
|
+
/** Null means the token never expires. */
|
|
56
|
+
expiresAt: string | null;
|
|
57
|
+
lastUsedAt: string | null;
|
|
58
|
+
scopeKind: string;
|
|
59
|
+
} | null;
|
|
60
|
+
/** Present only for a human session; null for a token principal. */
|
|
61
|
+
user: {
|
|
62
|
+
id: string;
|
|
63
|
+
identifier: string;
|
|
64
|
+
} | null;
|
|
65
|
+
/** Every channel the principal may act on. */
|
|
66
|
+
channels: Array<{
|
|
67
|
+
id: string;
|
|
68
|
+
code: string;
|
|
69
|
+
permissions: string[];
|
|
70
|
+
}>;
|
|
71
|
+
/** Null means unrestricted — location restriction is not implemented yet. */
|
|
72
|
+
locations: string[] | null;
|
|
73
|
+
/** Effective permissions on the ACTIVE channel, not the union of all of them. */
|
|
74
|
+
permissions: string[];
|
|
75
|
+
/** Connected plugin-catalogue keys for the active channel. */
|
|
76
|
+
entitlements: string[];
|
|
77
|
+
/** Reserved for per-token rate limits; always null until they exist. */
|
|
78
|
+
rateLimit: null;
|
|
79
|
+
}
|
|
80
|
+
export interface ApiToken {
|
|
81
|
+
id: string;
|
|
82
|
+
name: string;
|
|
83
|
+
tokenPrefix: string;
|
|
84
|
+
permissions: string[];
|
|
85
|
+
channelId: string;
|
|
86
|
+
/**
|
|
87
|
+
* ISO-8601 instant, or null for a token that never expires — the Admin API
|
|
88
|
+
* models `expiresAt` as nullable and the service returns null when neither
|
|
89
|
+
* `expiresAt` nor `expiresInDays` was given.
|
|
90
|
+
*/
|
|
91
|
+
expiresAt: string | null;
|
|
92
|
+
lastUsedAt: string | null;
|
|
93
|
+
revokedAt: string | null;
|
|
94
|
+
createdAt: string;
|
|
95
|
+
}
|
|
96
|
+
export interface CreateApiTokenInput {
|
|
97
|
+
name: string;
|
|
98
|
+
/** Explicit grants. Union with whatever `templateKeys` expands to. */
|
|
99
|
+
permissions?: string[];
|
|
100
|
+
/** Named presets from the platform's permission catalogue. */
|
|
101
|
+
templateKeys?: string[];
|
|
102
|
+
/**
|
|
103
|
+
* ISO-8601 instant WITH an offset; the engine refuses a past date. Wins over
|
|
104
|
+
* `expiresInDays`. Omit BOTH and the token never expires — the engine allows
|
|
105
|
+
* it, so the SDK does too rather than inventing a policy.
|
|
106
|
+
*/
|
|
107
|
+
expiresAt?: string;
|
|
108
|
+
expiresInDays?: number;
|
|
109
|
+
/** Defaults to the client's own tenant channel. */
|
|
110
|
+
channelId?: string;
|
|
111
|
+
}
|
|
112
|
+
/** Expiry is absent on purpose: it is fixed at creation (ADR 2026-07-29). */
|
|
113
|
+
export interface UpdateApiTokenInput {
|
|
114
|
+
name?: string;
|
|
115
|
+
permissions?: string[];
|
|
116
|
+
templateKeys?: string[];
|
|
117
|
+
}
|
|
118
|
+
export type { ChannelInfo, TenantContext, TenantScope };
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sixtyninecommerce/admin",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Back-office SDK for sixtynine-commerce: every capability of the platform as a method",
|
|
5
|
+
"homepage": "https://github.com/SIXTYNINE-digital/sixtynine-commerce-engine/tree/main/packages/admin-client#readme",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/SIXTYNINE-digital/sixtynine-commerce-engine.git",
|
|
9
|
+
"directory": "packages/admin-client"
|
|
10
|
+
},
|
|
11
|
+
"bugs": "https://github.com/SIXTYNINE-digital/sixtynine-commerce-engine/issues",
|
|
12
|
+
"type": "module",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"import": "./dist/index.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"keywords": [
|
|
21
|
+
"ecommerce",
|
|
22
|
+
"sdk",
|
|
23
|
+
"headless",
|
|
24
|
+
"admin",
|
|
25
|
+
"vendure"
|
|
26
|
+
],
|
|
27
|
+
"sideEffects": false,
|
|
28
|
+
"files": [
|
|
29
|
+
"dist",
|
|
30
|
+
"README.md"
|
|
31
|
+
],
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@sixtyninecommerce/core": "0.2.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/node": "22.19.7",
|
|
40
|
+
"typescript": "5.9.3",
|
|
41
|
+
"vitest": "4.1.6"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "tsc -p tsconfig.build.json",
|
|
45
|
+
"dev": "tsc -p tsconfig.build.json --watch",
|
|
46
|
+
"typecheck": "tsc --noEmit",
|
|
47
|
+
"test": "vitest run",
|
|
48
|
+
"test:watch": "vitest",
|
|
49
|
+
"test:unit": "vitest run",
|
|
50
|
+
"release:publish": "pnpm pack && npm publish *.tgz --access public"
|
|
51
|
+
}
|
|
52
|
+
}
|