@agentforge-io/sdk-console 0.0.0-stage → 0.2.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 (40) hide show
  1. package/README.md +172 -2
  2. package/dist/client.d.ts +43 -0
  3. package/dist/client.js +58 -0
  4. package/dist/errors.d.ts +25 -0
  5. package/dist/errors.js +93 -0
  6. package/dist/http.d.ts +76 -0
  7. package/dist/http.js +289 -0
  8. package/dist/index.d.ts +20 -0
  9. package/dist/index.js +57 -0
  10. package/dist/oauth.d.ts +37 -0
  11. package/dist/oauth.js +97 -0
  12. package/dist/resources/agents.d.ts +40 -0
  13. package/dist/resources/agents.js +67 -0
  14. package/dist/resources/apps.d.ts +16 -0
  15. package/dist/resources/apps.js +26 -0
  16. package/dist/resources/auth.d.ts +50 -0
  17. package/dist/resources/auth.js +87 -0
  18. package/dist/resources/connectors.d.ts +25 -0
  19. package/dist/resources/connectors.js +47 -0
  20. package/dist/resources/marketplace.d.ts +10 -0
  21. package/dist/resources/marketplace.js +14 -0
  22. package/dist/resources/members.d.ts +62 -0
  23. package/dist/resources/members.js +85 -0
  24. package/dist/resources/playground.d.ts +22 -0
  25. package/dist/resources/playground.js +32 -0
  26. package/dist/resources/teams.d.ts +49 -0
  27. package/dist/resources/teams.js +78 -0
  28. package/dist/resources/templates.d.ts +115 -0
  29. package/dist/resources/templates.js +187 -0
  30. package/dist/resources/tenants.d.ts +12 -0
  31. package/dist/resources/tenants.js +25 -0
  32. package/dist/resources/tools.d.ts +13 -0
  33. package/dist/resources/tools.js +17 -0
  34. package/dist/resources/variables.d.ts +28 -0
  35. package/dist/resources/variables.js +43 -0
  36. package/dist/token-store.d.ts +23 -0
  37. package/dist/token-store.js +27 -0
  38. package/dist/types.d.ts +1009 -0
  39. package/dist/types.js +19 -0
  40. package/package.json +44 -4
@@ -0,0 +1,115 @@
1
+ import type { HttpCore } from '../http';
2
+ import type { InstallTemplateInput, ListTemplatesInput, SaveTemplateInput, SignListingAssetInput, SignedUpload, Template, TemplateConfigField, TemplateConfigFields, TemplateInstallResult, TemplateListingPatch, TemplatePolicyCheck, TemplateReadiness, TemplateSourceStatus, TemplateVersionRow, TemplateVersionView, UpdateFromTemplateResult, UpdatesAvailable, VersionDiff, VersionHistory } from '../types';
3
+ export declare class TemplatesResource {
4
+ protected readonly http: HttpCore;
5
+ constructor(http: HttpCore);
6
+ /** `GET /public/templates`: system + public, listed rows only. */
7
+ listPublic(input?: Omit<ListTemplatesInput, 'publisherAppId'>): Promise<{
8
+ items: Template[];
9
+ }>;
10
+ /** `GET /public/templates/:id` (404 for tenant-private or unlisted rows). */
11
+ getPublic(templateId: string): Promise<Template>;
12
+ /** `GET /templates/:id` (with payload). */
13
+ get(templateId: string): Promise<Template>;
14
+ /** `PATCH /templates/:id`: metadata + listing (name, logo, cover, categories, guide, locale). */
15
+ updateListing(templateId: string, patch: TemplateListingPatch): Promise<Template>;
16
+ /** `GET /templates/:id/policy-check`: dry run of an App's template policy against a version
17
+ * (default: open draft, else published). `publisherAppId` defaults to the template's own publisher. */
18
+ policyCheck(templateId: string, input?: {
19
+ publisherAppId?: string;
20
+ version?: number;
21
+ }): Promise<TemplatePolicyCheck>;
22
+ /** `POST /templates/:id/listing-assets/sign`: PUT the bytes to `uploadUrl`, then `updateListing({ logoUrl | coverUrl: publicUrl })`. */
23
+ signListingAsset(templateId: string, input: SignListingAssetInput): Promise<SignedUpload>;
24
+ /** `GET /templates/:id/versions` (published snapshots). */
25
+ listVersions(templateId: string): Promise<{
26
+ items: TemplateVersionRow[];
27
+ }>;
28
+ /** `GET /templates/:id/version-history` */
29
+ versionHistory(templateId: string): Promise<VersionHistory>;
30
+ /** `GET /templates/:id/diff?from=&to=`; `to: 'source'` compares with the live source team. */
31
+ diff(templateId: string, from: number, to: number | 'source'): Promise<VersionDiff>;
32
+ /** `POST /templates/:id/drafts`: snapshot the source team as a new draft version. */
33
+ snapshotDraft(templateId: string): Promise<TemplateVersionView>;
34
+ /** `POST /templates/:id/versions/:v/submit`: draft -> in review. */
35
+ submitVersion(templateId: string, version: number, changelog: string): Promise<TemplateVersionView>;
36
+ /** `POST /templates/:id/versions/:v/review` */
37
+ reviewVersion(templateId: string, version: number, decision: 'approved' | 'changes_requested', comment?: string): Promise<TemplateVersionView>;
38
+ /** `POST /templates/:id/versions/:v/publish` */
39
+ publishVersion(templateId: string, version: number, changelog?: string): Promise<TemplateVersionView>;
40
+ /** `DELETE /templates/:id/versions/:v`: discard a draft. */
41
+ discardVersion(templateId: string, version: number): Promise<{
42
+ ok: true;
43
+ }>;
44
+ /** `POST /templates/:id/versions/:v/restore`: new draft from an old version. */
45
+ restoreVersion(templateId: string, version: number): Promise<TemplateVersionView>;
46
+ /** `PUT /templates/:id/source`: make a team of the template's workspace its source. */
47
+ linkSource(templateId: string, teamId: string): Promise<{
48
+ ok: true;
49
+ }>;
50
+ /** `DELETE /templates/:id/source` */
51
+ unlinkSource(templateId: string): Promise<{
52
+ ok: true;
53
+ }>;
54
+ /** `POST /templates/:id/source/copy`: create the editable copy from the published version and link it. */
55
+ createSourceCopy(templateId: string): Promise<{
56
+ teamId: string;
57
+ }>;
58
+ /** `PATCH /templates/:id/review-policy` */
59
+ setReviewPolicy(templateId: string, policy: {
60
+ requiredApprovals: number | null;
61
+ approverUserIds: string[] | null;
62
+ }): Promise<{
63
+ ok: true;
64
+ }>;
65
+ /** `GET /templates/:id/config-fields` (open draft, else published). */
66
+ configFields(templateId: string): Promise<TemplateConfigFields>;
67
+ /** `PUT /templates/:id/config-fields` (saved on the open draft). 400 `invalid_config_schema` if malformed. */
68
+ setConfigFields(templateId: string, configSchema: TemplateConfigField[]): Promise<{
69
+ draftVersion: number | null;
70
+ }>;
71
+ }
72
+ /** `forTenant(id).templates`: everything of `client.templates` plus the workspace-bound calls. */
73
+ export declare class TenantTemplatesResource extends TemplatesResource {
74
+ private readonly tenantId;
75
+ constructor(http: HttpCore, tenantId: string);
76
+ private get tenantBase();
77
+ /** `GET /templates?tenantId=`: system + public + this workspace's own. */
78
+ list(input?: ListTemplatesInput): Promise<{
79
+ items: Template[];
80
+ }>;
81
+ /** `POST /templates/:id/install` into this workspace. */
82
+ install(templateId: string, input?: InstallTemplateInput): Promise<TemplateInstallResult>;
83
+ /** `GET /templates/:id/install-readiness?destinationTenantId=`: what is ready / needs setup before installing here. */
84
+ installReadiness(templateId: string): Promise<TemplateReadiness>;
85
+ /** `POST /admin/tenants/:tenantId/agents/:agentId/save-as-template` */
86
+ saveAgentAsTemplate(agentId: string, input?: SaveTemplateInput): Promise<Template>;
87
+ /** `POST /admin/tenants/:tenantId/teams/:teamId/save-as-template` */
88
+ saveTeamAsTemplate(teamId: string, input?: SaveTemplateInput): Promise<Template>;
89
+ /** `POST /admin/tenants/:tenantId/agents/:agentId/publish-template-version` */
90
+ publishAgentTemplateVersion(agentId: string, input: {
91
+ templateId: string;
92
+ changelog?: string;
93
+ publisherAppId?: string | null;
94
+ }): Promise<Template>;
95
+ /** `POST /admin/tenants/:tenantId/teams/:teamId/publish-template-version` */
96
+ publishTeamTemplateVersion(teamId: string, input: {
97
+ templateId: string;
98
+ changelog?: string;
99
+ publisherAppId?: string | null;
100
+ }): Promise<Template>;
101
+ /** `GET /admin/tenants/:tenantId/teams/:teamId/template-source`: the template this team is the source of, with its version state. */
102
+ templateSource(teamId: string): Promise<{
103
+ source: TemplateSourceStatus | null;
104
+ }>;
105
+ /** `GET /me/template-updates-available?tenantId=`: installed agents/teams behind their template. */
106
+ updatesAvailable(): Promise<UpdatesAvailable>;
107
+ /** `POST /admin/tenants/:tenantId/teams/:teamId/update-from-template` */
108
+ updateTeamFromTemplate(teamId: string, input?: {
109
+ targetVersion?: number;
110
+ }): Promise<UpdateFromTemplateResult>;
111
+ /** `POST /admin/tenants/:tenantId/agents/:agentId/update-from-template` */
112
+ updateAgentFromTemplate(agentId: string, input?: {
113
+ targetVersion?: number;
114
+ }): Promise<UpdateFromTemplateResult>;
115
+ }
@@ -0,0 +1,187 @@
1
+ "use strict";
2
+ // templates: gallery, detail, listing, version lifecycle (`client.templates`),
3
+ // plus the workspace-bound calls (`forTenant(id).templates`): install, save as
4
+ // template, publish a version, updates of installed teams.
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.TenantTemplatesResource = exports.TemplatesResource = void 0;
7
+ const http_1 = require("../http");
8
+ function listQuery(input) {
9
+ return {
10
+ kind: input.kind,
11
+ q: input.q,
12
+ categories: input.categories,
13
+ primaryCategory: input.primaryCategory,
14
+ publisherAppId: input.publisherAppId,
15
+ limit: input.limit,
16
+ };
17
+ }
18
+ class TemplatesResource {
19
+ constructor(http) {
20
+ this.http = http;
21
+ }
22
+ // ─── Public gallery (no session) ─────────────────────────────────────
23
+ /** `GET /public/templates`: system + public, listed rows only. */
24
+ async listPublic(input = {}) {
25
+ return this.http.request('GET', '/public/templates', { query: listQuery(input), auth: false });
26
+ }
27
+ /** `GET /public/templates/:id` (404 for tenant-private or unlisted rows). */
28
+ async getPublic(templateId) {
29
+ return this.http.request('GET', `/public/templates/${(0, http_1.seg)(templateId)}`, { auth: false });
30
+ }
31
+ // ─── Detail & listing ────────────────────────────────────────────────
32
+ /** `GET /templates/:id` (with payload). */
33
+ async get(templateId) {
34
+ return this.http.request('GET', `/templates/${(0, http_1.seg)(templateId)}`);
35
+ }
36
+ /** `PATCH /templates/:id`: metadata + listing (name, logo, cover, categories, guide, locale). */
37
+ async updateListing(templateId, patch) {
38
+ return this.http.request('PATCH', `/templates/${(0, http_1.seg)(templateId)}`, { body: patch });
39
+ }
40
+ /** `GET /templates/:id/policy-check`: dry run of an App's template policy against a version
41
+ * (default: open draft, else published). `publisherAppId` defaults to the template's own publisher. */
42
+ async policyCheck(templateId, input = {}) {
43
+ return this.http.request('GET', `/templates/${(0, http_1.seg)(templateId)}/policy-check`, {
44
+ query: { publisherAppId: input.publisherAppId, version: input.version },
45
+ });
46
+ }
47
+ /** `POST /templates/:id/listing-assets/sign`: PUT the bytes to `uploadUrl`, then `updateListing({ logoUrl | coverUrl: publicUrl })`. */
48
+ async signListingAsset(templateId, input) {
49
+ return this.http.request('POST', `/templates/${(0, http_1.seg)(templateId)}/listing-assets/sign`, { body: input });
50
+ }
51
+ /** `GET /templates/:id/versions` (published snapshots). */
52
+ async listVersions(templateId) {
53
+ return this.http.request('GET', `/templates/${(0, http_1.seg)(templateId)}/versions`);
54
+ }
55
+ // ─── Version lifecycle (AGF-TEMPLATE-VERSIONS) ───────────────────────
56
+ /** `GET /templates/:id/version-history` */
57
+ async versionHistory(templateId) {
58
+ return this.http.request('GET', `/templates/${(0, http_1.seg)(templateId)}/version-history`);
59
+ }
60
+ /** `GET /templates/:id/diff?from=&to=`; `to: 'source'` compares with the live source team. */
61
+ async diff(templateId, from, to) {
62
+ return this.http.request('GET', `/templates/${(0, http_1.seg)(templateId)}/diff`, { query: { from, to } });
63
+ }
64
+ /** `POST /templates/:id/drafts`: snapshot the source team as a new draft version. */
65
+ async snapshotDraft(templateId) {
66
+ return this.http.request('POST', `/templates/${(0, http_1.seg)(templateId)}/drafts`, { body: {} });
67
+ }
68
+ /** `POST /templates/:id/versions/:v/submit`: draft -> in review. */
69
+ async submitVersion(templateId, version, changelog) {
70
+ return this.http.request('POST', `/templates/${(0, http_1.seg)(templateId)}/versions/${version}/submit`, {
71
+ body: { changelog },
72
+ });
73
+ }
74
+ /** `POST /templates/:id/versions/:v/review` */
75
+ async reviewVersion(templateId, version, decision, comment) {
76
+ return this.http.request('POST', `/templates/${(0, http_1.seg)(templateId)}/versions/${version}/review`, {
77
+ body: { decision, comment },
78
+ });
79
+ }
80
+ /** `POST /templates/:id/versions/:v/publish` */
81
+ async publishVersion(templateId, version, changelog) {
82
+ return this.http.request('POST', `/templates/${(0, http_1.seg)(templateId)}/versions/${version}/publish`, {
83
+ body: { changelog },
84
+ });
85
+ }
86
+ /** `DELETE /templates/:id/versions/:v`: discard a draft. */
87
+ async discardVersion(templateId, version) {
88
+ return this.http.request('DELETE', `/templates/${(0, http_1.seg)(templateId)}/versions/${version}`);
89
+ }
90
+ /** `POST /templates/:id/versions/:v/restore`: new draft from an old version. */
91
+ async restoreVersion(templateId, version) {
92
+ return this.http.request('POST', `/templates/${(0, http_1.seg)(templateId)}/versions/${version}/restore`, { body: {} });
93
+ }
94
+ /** `PUT /templates/:id/source`: make a team of the template's workspace its source. */
95
+ async linkSource(templateId, teamId) {
96
+ return this.http.request('PUT', `/templates/${(0, http_1.seg)(templateId)}/source`, { body: { teamId } });
97
+ }
98
+ /** `DELETE /templates/:id/source` */
99
+ async unlinkSource(templateId) {
100
+ return this.http.request('DELETE', `/templates/${(0, http_1.seg)(templateId)}/source`);
101
+ }
102
+ /** `POST /templates/:id/source/copy`: create the editable copy from the published version and link it. */
103
+ async createSourceCopy(templateId) {
104
+ return this.http.request('POST', `/templates/${(0, http_1.seg)(templateId)}/source/copy`, { body: {} });
105
+ }
106
+ /** `PATCH /templates/:id/review-policy` */
107
+ async setReviewPolicy(templateId, policy) {
108
+ return this.http.request('PATCH', `/templates/${(0, http_1.seg)(templateId)}/review-policy`, { body: policy });
109
+ }
110
+ // ─── Business settings the template asks for ─────────────────────────
111
+ /** `GET /templates/:id/config-fields` (open draft, else published). */
112
+ async configFields(templateId) {
113
+ return this.http.request('GET', `/templates/${(0, http_1.seg)(templateId)}/config-fields`);
114
+ }
115
+ /** `PUT /templates/:id/config-fields` (saved on the open draft). 400 `invalid_config_schema` if malformed. */
116
+ async setConfigFields(templateId, configSchema) {
117
+ return this.http.request('PUT', `/templates/${(0, http_1.seg)(templateId)}/config-fields`, { body: { configSchema } });
118
+ }
119
+ }
120
+ exports.TemplatesResource = TemplatesResource;
121
+ /** `forTenant(id).templates`: everything of `client.templates` plus the workspace-bound calls. */
122
+ class TenantTemplatesResource extends TemplatesResource {
123
+ constructor(http, tenantId) {
124
+ super(http);
125
+ this.tenantId = tenantId;
126
+ }
127
+ get tenantBase() {
128
+ return `/admin/tenants/${(0, http_1.seg)(this.tenantId)}`;
129
+ }
130
+ /** `GET /templates?tenantId=`: system + public + this workspace's own. */
131
+ async list(input = {}) {
132
+ return this.http.request('GET', '/templates', { query: { tenantId: this.tenantId, ...listQuery(input) } });
133
+ }
134
+ /** `POST /templates/:id/install` into this workspace. */
135
+ async install(templateId, input = {}) {
136
+ return this.http.request('POST', `/templates/${(0, http_1.seg)(templateId)}/install`, {
137
+ body: { destinationTenantId: this.tenantId, ...input },
138
+ });
139
+ }
140
+ /** `GET /templates/:id/install-readiness?destinationTenantId=`: what is ready / needs setup before installing here. */
141
+ async installReadiness(templateId) {
142
+ return this.http.request('GET', `/templates/${(0, http_1.seg)(templateId)}/install-readiness`, {
143
+ query: { destinationTenantId: this.tenantId },
144
+ });
145
+ }
146
+ /** `POST /admin/tenants/:tenantId/agents/:agentId/save-as-template` */
147
+ async saveAgentAsTemplate(agentId, input = {}) {
148
+ return this.http.request('POST', `${this.tenantBase}/agents/${(0, http_1.seg)(agentId)}/save-as-template`, { body: input });
149
+ }
150
+ /** `POST /admin/tenants/:tenantId/teams/:teamId/save-as-template` */
151
+ async saveTeamAsTemplate(teamId, input = {}) {
152
+ return this.http.request('POST', `${this.tenantBase}/teams/${(0, http_1.seg)(teamId)}/save-as-template`, { body: input });
153
+ }
154
+ /** `POST /admin/tenants/:tenantId/agents/:agentId/publish-template-version` */
155
+ async publishAgentTemplateVersion(agentId, input) {
156
+ return this.http.request('POST', `${this.tenantBase}/agents/${(0, http_1.seg)(agentId)}/publish-template-version`, {
157
+ body: input,
158
+ });
159
+ }
160
+ /** `POST /admin/tenants/:tenantId/teams/:teamId/publish-template-version` */
161
+ async publishTeamTemplateVersion(teamId, input) {
162
+ return this.http.request('POST', `${this.tenantBase}/teams/${(0, http_1.seg)(teamId)}/publish-template-version`, {
163
+ body: input,
164
+ });
165
+ }
166
+ /** `GET /admin/tenants/:tenantId/teams/:teamId/template-source`: the template this team is the source of, with its version state. */
167
+ async templateSource(teamId) {
168
+ return this.http.request('GET', `${this.tenantBase}/teams/${(0, http_1.seg)(teamId)}/template-source`);
169
+ }
170
+ /** `GET /me/template-updates-available?tenantId=`: installed agents/teams behind their template. */
171
+ async updatesAvailable() {
172
+ return this.http.request('GET', '/me/template-updates-available', { query: { tenantId: this.tenantId } });
173
+ }
174
+ /** `POST /admin/tenants/:tenantId/teams/:teamId/update-from-template` */
175
+ async updateTeamFromTemplate(teamId, input = {}) {
176
+ return this.http.request('POST', `${this.tenantBase}/teams/${(0, http_1.seg)(teamId)}/update-from-template`, {
177
+ body: input,
178
+ });
179
+ }
180
+ /** `POST /admin/tenants/:tenantId/agents/:agentId/update-from-template` */
181
+ async updateAgentFromTemplate(agentId, input = {}) {
182
+ return this.http.request('POST', `${this.tenantBase}/agents/${(0, http_1.seg)(agentId)}/update-from-template`, {
183
+ body: input,
184
+ });
185
+ }
186
+ }
187
+ exports.TenantTemplatesResource = TenantTemplatesResource;
@@ -0,0 +1,12 @@
1
+ import type { HttpCore } from '../http';
2
+ import type { CreateTenantInput, ListTenantsInput, Tenant, TenantList, UpdateTenantInput } from '../types';
3
+ export declare class TenantsResource {
4
+ private readonly http;
5
+ constructor(http: HttpCore);
6
+ /** `GET /me/tenants` */
7
+ listMine(input?: ListTenantsInput): Promise<TenantList>;
8
+ /** `POST /admin/tenants`. The caller becomes the owner. */
9
+ create(input: CreateTenantInput): Promise<Tenant>;
10
+ /** `PATCH /admin/tenants/:tenantId` */
11
+ update(tenantId: string, patch: UpdateTenantInput): Promise<Tenant>;
12
+ }
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ // tenants: the user's workspaces. `GET /me/tenants` (owned + member, with
3
+ // `myRole`) feeds the switcher. The server has no `GET /admin/tenants/:id`:
4
+ // read one from `listMine`.
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.TenantsResource = void 0;
7
+ const http_1 = require("../http");
8
+ class TenantsResource {
9
+ constructor(http) {
10
+ this.http = http;
11
+ }
12
+ /** `GET /me/tenants` */
13
+ async listMine(input = {}) {
14
+ return this.http.request('GET', '/me/tenants', { query: { ...input } });
15
+ }
16
+ /** `POST /admin/tenants`. The caller becomes the owner. */
17
+ async create(input) {
18
+ return this.http.request('POST', '/admin/tenants', { body: input });
19
+ }
20
+ /** `PATCH /admin/tenants/:tenantId` */
21
+ async update(tenantId, patch) {
22
+ return this.http.request('PATCH', `/admin/tenants/${(0, http_1.seg)(tenantId)}`, { body: patch });
23
+ }
24
+ }
25
+ exports.TenantsResource = TenantsResource;
@@ -0,0 +1,13 @@
1
+ import type { HttpCore } from '../http';
2
+ import type { ToolGroup } from '../types';
3
+ export declare class ToolsResource {
4
+ private readonly http;
5
+ private readonly tenantId;
6
+ constructor(http: HttpCore, tenantId: string);
7
+ /** `GET /tools/grouped?tenantId=&q=` */
8
+ grouped(input?: {
9
+ q?: string;
10
+ }): Promise<{
11
+ groups: ToolGroup[];
12
+ }>;
13
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ // tools: the tool catalog, grouped by source (connector / MCP / built-in).
3
+ // `forTenant(id).tools`. Feeds the agent editor's tool picker.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.ToolsResource = void 0;
6
+ class ToolsResource {
7
+ constructor(http, tenantId) {
8
+ this.http = http;
9
+ this.tenantId = tenantId;
10
+ }
11
+ /** `GET /tools/grouped?tenantId=&q=` */
12
+ async grouped(input = {}) {
13
+ const q = input.q?.trim();
14
+ return this.http.request('GET', '/tools/grouped', { query: { tenantId: this.tenantId, q: q || undefined } });
15
+ }
16
+ }
17
+ exports.ToolsResource = ToolsResource;
@@ -0,0 +1,28 @@
1
+ import type { HttpCore } from '../http';
2
+ import type { TenantVariable, UpsertTenantVariableInput } from '../types';
3
+ export declare class VariablesResource {
4
+ private readonly http;
5
+ private readonly tenantId;
6
+ constructor(http: HttpCore, tenantId: string);
7
+ private get base();
8
+ /** `GET /tenants/:tenantId/variables?q=`. Members get config variables
9
+ * (with `value`); owner/admin also get secrets (`valueHint` only). */
10
+ list(input?: {
11
+ q?: string;
12
+ }): Promise<{
13
+ items: TenantVariable[];
14
+ }>;
15
+ /** `GET .../variables/:key` (same visibility as the list; 404 when absent). */
16
+ get(key: string): Promise<TenantVariable>;
17
+ /** `PUT .../variables/:key`. Owner/admin only. `kind` omitted keeps the
18
+ * current kind (new variables default to `secret`); turning an existing
19
+ * secret into config is a 409 `variable_kind_conflict`. `value` is a
20
+ * non-empty string of at most 10 000 characters. Resolves to the stored
21
+ * entry: a secret comes back as a hint, never the value. */
22
+ upsert(key: string, input: UpsertTenantVariableInput): Promise<TenantVariable>;
23
+ /** `DELETE .../variables/:key`. Owner/admin only. 409 `has_bindings`
24
+ * (details.bindings) unless `force`. */
25
+ remove(key: string, options?: {
26
+ force?: boolean;
27
+ }): Promise<void>;
28
+ }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ // Workspace variables (`forTenant(id).variables`): business data a template
3
+ // reads through `{{config:KEY}}` (config, readable) or `{{secret:KEY}}`
4
+ // (secret, write-only: the platform only ever returns a 4-char hint).
5
+ // Server: `TenantVariablesController` at `/tenants/:tenantId/variables`
6
+ // (no `admin/` prefix: plain members read config).
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.VariablesResource = void 0;
9
+ const http_1 = require("../http");
10
+ class VariablesResource {
11
+ constructor(http, tenantId) {
12
+ this.http = http;
13
+ this.tenantId = tenantId;
14
+ }
15
+ get base() {
16
+ return `/tenants/${(0, http_1.seg)(this.tenantId)}/variables`;
17
+ }
18
+ /** `GET /tenants/:tenantId/variables?q=`. Members get config variables
19
+ * (with `value`); owner/admin also get secrets (`valueHint` only). */
20
+ async list(input = {}) {
21
+ return this.http.request('GET', this.base, { query: { q: input.q } });
22
+ }
23
+ /** `GET .../variables/:key` (same visibility as the list; 404 when absent). */
24
+ async get(key) {
25
+ return this.http.request('GET', `${this.base}/${(0, http_1.seg)(key)}`);
26
+ }
27
+ /** `PUT .../variables/:key`. Owner/admin only. `kind` omitted keeps the
28
+ * current kind (new variables default to `secret`); turning an existing
29
+ * secret into config is a 409 `variable_kind_conflict`. `value` is a
30
+ * non-empty string of at most 10 000 characters. Resolves to the stored
31
+ * entry: a secret comes back as a hint, never the value. */
32
+ async upsert(key, input) {
33
+ return this.http.request('PUT', `${this.base}/${(0, http_1.seg)(key)}`, { body: input });
34
+ }
35
+ /** `DELETE .../variables/:key`. Owner/admin only. 409 `has_bindings`
36
+ * (details.bindings) unless `force`. */
37
+ async remove(key, options = {}) {
38
+ await this.http.request('DELETE', `${this.base}/${(0, http_1.seg)(key)}`, {
39
+ query: { force: options.force ? true : undefined },
40
+ });
41
+ }
42
+ }
43
+ exports.VariablesResource = VariablesResource;
@@ -0,0 +1,23 @@
1
+ export type MaybePromise<T> = T | Promise<T>;
2
+ export interface AuthTokens {
3
+ accessToken: string;
4
+ refreshToken: string;
5
+ }
6
+ export interface TokenStore {
7
+ getAccessToken(): MaybePromise<string | null>;
8
+ getRefreshToken(): MaybePromise<string | null>;
9
+ /** Persist a fresh pair (login, register, invite accept, refresh rotation). */
10
+ setTokens(tokens: AuthTokens): MaybePromise<void>;
11
+ /** Wipe both tokens (sign out). */
12
+ clear(): MaybePromise<void>;
13
+ }
14
+ /** In-memory store: tests, SSR, or an app that does not persist the session. */
15
+ export declare class MemoryTokenStore implements TokenStore {
16
+ private access;
17
+ private refresh;
18
+ constructor(initial?: Partial<AuthTokens>);
19
+ getAccessToken(): string | null;
20
+ getRefreshToken(): string | null;
21
+ setTokens(tokens: AuthTokens): void;
22
+ clear(): void;
23
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ // Where the session tokens live. The app plugs its own storage: SecureStore on
3
+ // native, localStorage / memory on web. Every method may be sync or async.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.MemoryTokenStore = void 0;
6
+ /** In-memory store: tests, SSR, or an app that does not persist the session. */
7
+ class MemoryTokenStore {
8
+ constructor(initial) {
9
+ this.access = initial?.accessToken ?? null;
10
+ this.refresh = initial?.refreshToken ?? null;
11
+ }
12
+ getAccessToken() {
13
+ return this.access;
14
+ }
15
+ getRefreshToken() {
16
+ return this.refresh;
17
+ }
18
+ setTokens(tokens) {
19
+ this.access = tokens.accessToken;
20
+ this.refresh = tokens.refreshToken;
21
+ }
22
+ clear() {
23
+ this.access = null;
24
+ this.refresh = null;
25
+ }
26
+ }
27
+ exports.MemoryTokenStore = MemoryTokenStore;