@xmodelin/dsh-collab-auth-api 0.0.3 → 0.0.4

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/lib/host.js CHANGED
@@ -21,6 +21,23 @@ export function apply(ctx) {
21
21
  list: () => { assertOwner(); return admin().listAuth(); },
22
22
  authorize: (a, b) => { assertOwner(); return admin().authorize(a, b); },
23
23
  revoke: (a, b) => { assertOwner(); return admin().revoke(a, b); },
24
+ board: (sessionId) => { assertOwner(); return JSON.stringify(admin().board(sessionId)); },
25
+ link: (sessionId, worker, payloadJson) => {
26
+ assertOwner();
27
+ let payload = {};
28
+ if (payloadJson.trim().length > 0) {
29
+ const parsed = JSON.parse(payloadJson);
30
+ if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed))
31
+ throw new Error('link payload must be a JSON object');
32
+ payload = parsed;
33
+ }
34
+ return JSON.stringify(admin().link(sessionId, worker, payload));
35
+ },
36
+ unlink: (sessionId, worker) => { assertOwner(); return JSON.stringify(admin().unlink(sessionId, worker)); },
37
+ pin: (sessionId, worker) => { assertOwner(); return JSON.stringify(admin().pin(sessionId, worker)); },
38
+ live: (sessionId, worker) => { assertOwner(); return JSON.stringify(admin().live(sessionId, worker)); },
39
+ baseGet: (sessionId) => { assertOwner(); return JSON.stringify(admin().baseGet(sessionId)); },
40
+ baseSet: (sessionId, value) => { assertOwner(); return JSON.stringify(admin().baseSet(sessionId, value)); },
24
41
  panel: (sessionId, operation, argsJson) => {
25
42
  assertOwner();
26
43
  let args = {};
package/lib/index.d.ts CHANGED
@@ -48,12 +48,23 @@ export declare class CollabAuthService extends TypertRemoteService {
48
48
  */
49
49
  revoke(a: string, b: string): AuthSnapshot;
50
50
  /**
51
- * Read or mutate the supervisor board/base-prompt surface without writing a
52
- * slash-command lifecycle into the conversation.
51
+ * Read the supervisor board.
52
+ * @param sessionId - collaboration Session id.
53
+ * @returns JSON board snapshot.
54
+ */
55
+ board(sessionId: string): string;
56
+ link(sessionId: string, worker: string, payloadJson: string): string;
57
+ unlink(sessionId: string, worker: string): string;
58
+ pin(sessionId: string, worker: string): string;
59
+ live(sessionId: string, worker: string): string;
60
+ baseGet(sessionId: string): string;
61
+ baseSet(sessionId: string, value: string): string;
62
+ /**
63
+ * Read or mutate a supervisor management surface without a slash command.
53
64
  * @param sessionId - collaboration Session id.
54
65
  * @param operation - board, baseGet, baseSet, link, unlink, pin, or live.
55
- * @param args - operation-specific payload.
56
- * @returns the operation result.
66
+ * @param argsJson - JSON operation payload.
67
+ * @returns JSON operation result.
57
68
  */
58
69
  panel(sessionId: string, operation: string, argsJson: string): string;
59
70
  }
package/lib/index.js CHANGED
@@ -47,6 +47,9 @@ function sessionId(value, parameter) {
47
47
  throw new Error(`Invalid ${parameter}: ${value}`);
48
48
  return value;
49
49
  }
50
+ function sessionIdOf(value, parameter) {
51
+ return sessionId(value, parameter);
52
+ }
50
53
  /** Host service backing the generated `ctx.remote.collabAuth` namespace. */
51
54
  let CollabAuthService = (() => {
52
55
  let _classSuper = TypertRemoteService;
@@ -54,6 +57,13 @@ let CollabAuthService = (() => {
54
57
  let _list_decorators;
55
58
  let _authorize_decorators;
56
59
  let _revoke_decorators;
60
+ let _board_decorators;
61
+ let _link_decorators;
62
+ let _unlink_decorators;
63
+ let _pin_decorators;
64
+ let _live_decorators;
65
+ let _baseGet_decorators;
66
+ let _baseSet_decorators;
57
67
  let _panel_decorators;
58
68
  return class CollabAuthService extends _classSuper {
59
69
  static {
@@ -61,10 +71,24 @@ let CollabAuthService = (() => {
61
71
  _list_decorators = [Remote('list')];
62
72
  _authorize_decorators = [Remote({ name: 'authorize', resources: { session: (a, b) => [a, b] } })];
63
73
  _revoke_decorators = [Remote({ name: 'revoke', resources: { session: (a, b) => [a, b] } })];
74
+ _board_decorators = [Remote({ name: 'board', resources: { session: (sessionId) => sessionId } })];
75
+ _link_decorators = [Remote({ name: 'link', resources: { session: (sessionId) => sessionId } })];
76
+ _unlink_decorators = [Remote({ name: 'unlink', resources: { session: (sessionId) => sessionId } })];
77
+ _pin_decorators = [Remote({ name: 'pin', resources: { session: (sessionId) => sessionId } })];
78
+ _live_decorators = [Remote({ name: 'live', resources: { session: (sessionId) => sessionId } })];
79
+ _baseGet_decorators = [Remote({ name: 'baseGet', resources: { session: (sessionId) => sessionId } })];
80
+ _baseSet_decorators = [Remote({ name: 'baseSet', resources: { session: (sessionId) => sessionId } })];
64
81
  _panel_decorators = [Remote({ name: 'panel', resources: { session: (sessionId) => sessionId } })];
65
82
  __esDecorate(this, null, _list_decorators, { kind: "method", name: "list", static: false, private: false, access: { has: obj => "list" in obj, get: obj => obj.list }, metadata: _metadata }, null, _instanceExtraInitializers);
66
83
  __esDecorate(this, null, _authorize_decorators, { kind: "method", name: "authorize", static: false, private: false, access: { has: obj => "authorize" in obj, get: obj => obj.authorize }, metadata: _metadata }, null, _instanceExtraInitializers);
67
84
  __esDecorate(this, null, _revoke_decorators, { kind: "method", name: "revoke", static: false, private: false, access: { has: obj => "revoke" in obj, get: obj => obj.revoke }, metadata: _metadata }, null, _instanceExtraInitializers);
85
+ __esDecorate(this, null, _board_decorators, { kind: "method", name: "board", static: false, private: false, access: { has: obj => "board" in obj, get: obj => obj.board }, metadata: _metadata }, null, _instanceExtraInitializers);
86
+ __esDecorate(this, null, _link_decorators, { kind: "method", name: "link", static: false, private: false, access: { has: obj => "link" in obj, get: obj => obj.link }, metadata: _metadata }, null, _instanceExtraInitializers);
87
+ __esDecorate(this, null, _unlink_decorators, { kind: "method", name: "unlink", static: false, private: false, access: { has: obj => "unlink" in obj, get: obj => obj.unlink }, metadata: _metadata }, null, _instanceExtraInitializers);
88
+ __esDecorate(this, null, _pin_decorators, { kind: "method", name: "pin", static: false, private: false, access: { has: obj => "pin" in obj, get: obj => obj.pin }, metadata: _metadata }, null, _instanceExtraInitializers);
89
+ __esDecorate(this, null, _live_decorators, { kind: "method", name: "live", static: false, private: false, access: { has: obj => "live" in obj, get: obj => obj.live }, metadata: _metadata }, null, _instanceExtraInitializers);
90
+ __esDecorate(this, null, _baseGet_decorators, { kind: "method", name: "baseGet", static: false, private: false, access: { has: obj => "baseGet" in obj, get: obj => obj.baseGet }, metadata: _metadata }, null, _instanceExtraInitializers);
91
+ __esDecorate(this, null, _baseSet_decorators, { kind: "method", name: "baseSet", static: false, private: false, access: { has: obj => "baseSet" in obj, get: obj => obj.baseSet }, metadata: _metadata }, null, _instanceExtraInitializers);
68
92
  __esDecorate(this, null, _panel_decorators, { kind: "method", name: "panel", static: false, private: false, access: { has: obj => "panel" in obj, get: obj => obj.panel }, metadata: _metadata }, null, _instanceExtraInitializers);
69
93
  if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
70
94
  }
@@ -115,6 +139,7 @@ let CollabAuthService = (() => {
115
139
  * @param b - second Session id.
116
140
  * @returns the resulting authorization snapshot.
117
141
  */
142
+ // @ts-expect-error Typert reads the options object at build time.
118
143
  authorize(a, b) {
119
144
  this.assertOwner();
120
145
  return this.admin().authorize(sessionId(a, 'a'), sessionId(b, 'b'));
@@ -125,18 +150,68 @@ let CollabAuthService = (() => {
125
150
  * @param b - second Session id.
126
151
  * @returns the resulting authorization snapshot.
127
152
  */
153
+ // @ts-expect-error Typert reads the options object at build time.
128
154
  revoke(a, b) {
129
155
  this.assertOwner();
130
156
  return this.admin().revoke(sessionId(a, 'a'), sessionId(b, 'b'));
131
157
  }
132
158
  /**
133
- * Read or mutate the supervisor board/base-prompt surface without writing a
134
- * slash-command lifecycle into the conversation.
159
+ * Read the supervisor board.
160
+ * @param sessionId - collaboration Session id.
161
+ * @returns JSON board snapshot.
162
+ */
163
+ // @ts-expect-error Typert reads the options object at build time.
164
+ board(sessionId) {
165
+ this.assertOwner();
166
+ return JSON.stringify(this.admin().board(sessionIdOf(sessionId, 'sessionId')));
167
+ }
168
+ // @ts-expect-error Typert reads the options object at build time.
169
+ link(sessionId, worker, payloadJson) {
170
+ this.assertOwner();
171
+ const id = sessionIdOf(sessionId, 'sessionId');
172
+ const peer = sessionIdOf(worker, 'worker');
173
+ let payload = {};
174
+ if (payloadJson.trim().length > 0) {
175
+ const parsed = JSON.parse(payloadJson);
176
+ if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed))
177
+ throw new Error('link payload must be a JSON object');
178
+ payload = parsed;
179
+ }
180
+ return JSON.stringify(this.admin().link(id, peer, payload));
181
+ }
182
+ // @ts-expect-error Typert reads the options object at build time.
183
+ unlink(sessionId, worker) {
184
+ this.assertOwner();
185
+ return JSON.stringify(this.admin().unlink(sessionIdOf(sessionId, 'sessionId'), sessionIdOf(worker, 'worker')));
186
+ }
187
+ // @ts-expect-error Typert reads the options object at build time.
188
+ pin(sessionId, worker) {
189
+ this.assertOwner();
190
+ return JSON.stringify(this.admin().pin(sessionIdOf(sessionId, 'sessionId'), sessionIdOf(worker, 'worker')));
191
+ }
192
+ // @ts-expect-error Typert reads the options object at build time.
193
+ live(sessionId, worker) {
194
+ this.assertOwner();
195
+ return JSON.stringify(this.admin().live(sessionIdOf(sessionId, 'sessionId'), sessionIdOf(worker, 'worker')));
196
+ }
197
+ // @ts-expect-error Typert reads the options object at build time.
198
+ baseGet(sessionId) {
199
+ this.assertOwner();
200
+ return JSON.stringify(this.admin().baseGet(sessionIdOf(sessionId, 'sessionId')));
201
+ }
202
+ // @ts-expect-error Typert reads the options object at build time.
203
+ baseSet(sessionId, value) {
204
+ this.assertOwner();
205
+ return JSON.stringify(this.admin().baseSet(sessionIdOf(sessionId, 'sessionId'), value));
206
+ }
207
+ /**
208
+ * Read or mutate a supervisor management surface without a slash command.
135
209
  * @param sessionId - collaboration Session id.
136
210
  * @param operation - board, baseGet, baseSet, link, unlink, pin, or live.
137
- * @param args - operation-specific payload.
138
- * @returns the operation result.
211
+ * @param argsJson - JSON operation payload.
212
+ * @returns JSON operation result.
139
213
  */
214
+ // @ts-expect-error Typert reads the options object at build time.
140
215
  panel(sessionId, operation, argsJson) {
141
216
  this.assertOwner();
142
217
  const checkedSessionId = sessionId === undefined ? '' : sessionId;