@sasjs/api 0.35.0 → 0.36.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.
@@ -1,42 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VIYA_HANDLERS = exports.idFor = exports.EMULATED_USER = exports.EMULATED_NOW = void 0;
3
+ exports.VIYA_HANDLERS = void 0;
4
4
  const types_js_1 = require("../types.js");
5
- /** The emulated clock: a fixed instant, so a body is reproducible. */
6
- exports.EMULATED_NOW = '2026-01-01T00:00:00.000Z';
7
- /** The caller the emulated estate reports when a host does not name one. */
8
- exports.EMULATED_USER = { id: 'emulated-user', name: 'Emulated User' };
9
- /**
10
- * A uuid shape from a string, deterministically.
11
- *
12
- * Two 32-bit FNV-1a passes give enough of a hash to fill a uuid's fields, and the
13
- * version/variant nibbles are set so the result is a well-formed v4-shaped id.
14
- * Collisions are possible in principle and irrelevant here: the id is a handle
15
- * the emulator hands back, not a uniqueness guarantee.
16
- */
17
- const idFor = (path, kind = 'folder') => {
18
- const hash = (input, seed) => {
19
- let value = seed;
20
- for (let index = 0; index < input.length; index++) {
21
- value ^= input.charCodeAt(index);
22
- value = Math.imul(value, 16777619) >>> 0;
23
- }
24
- return value.toString(16).padStart(8, '0');
25
- };
26
- const raw = hash(`${kind}:${path}`, 2166136261) +
27
- hash(`${kind}:${path}`, 2246822519) +
28
- hash(`${kind}:${path}`, 3266489917) +
29
- hash(`${kind}:${path}`, 668265263);
30
- const hex = raw.slice(0, 32);
31
- return [
32
- hex.slice(0, 8),
33
- hex.slice(8, 12),
34
- `4${hex.slice(13, 16)}`,
35
- `a${hex.slice(17, 20)}`,
36
- hex.slice(20, 32)
37
- ].join('-');
38
- };
39
- exports.idFor = idFor;
5
+ const ports_js_1 = require("./ports.js");
6
+ const compute_js_1 = require("./compute.js");
7
+ const files_js_1 = require("./files.js");
8
+ const ids_js_1 = require("./ids.js");
40
9
  const linksFor = (uri, collection = false) => {
41
10
  const self = {
42
11
  href: uri,
@@ -59,7 +28,7 @@ const linksFor = (uri, collection = false) => {
59
28
  };
60
29
  const folderBody = async (drive, path) => {
61
30
  const listing = await drive.list(path);
62
- const id = (0, exports.idFor)(path);
31
+ const id = (0, ids_js_1.idFor)(path);
63
32
  const name = path.split('/').filter(Boolean).pop() ?? '';
64
33
  const parent = path.split('/').slice(0, -1).join('/') || '/';
65
34
  return {
@@ -68,49 +37,44 @@ const folderBody = async (drive, path) => {
68
37
  description: '',
69
38
  type: 'folder',
70
39
  version: 1,
71
- createdBy: exports.EMULATED_USER.id,
72
- modifiedBy: exports.EMULATED_USER.id,
73
- creationTimeStamp: exports.EMULATED_NOW,
74
- modifiedTimeStamp: exports.EMULATED_NOW,
40
+ createdBy: ids_js_1.EMULATED_USER.id,
41
+ modifiedBy: ids_js_1.EMULATED_USER.id,
42
+ creationTimeStamp: ids_js_1.EMULATED_NOW,
43
+ modifiedTimeStamp: ids_js_1.EMULATED_NOW,
75
44
  memberCount: listing.files.length + listing.folders.length,
76
- parentFolderUri: `/folders/folders/${(0, exports.idFor)(parent)}`,
45
+ parentFolderUri: `/folders/folders/${(0, ids_js_1.idFor)(parent)}`,
77
46
  links: linksFor(`/folders/folders/${id}`)
78
47
  };
79
48
  };
80
49
  const recycleBin = () => {
81
50
  const path = '@myRecycleBin';
82
- const id = (0, exports.idFor)(path);
51
+ const id = (0, ids_js_1.idFor)(path);
83
52
  return {
84
53
  id,
85
54
  name: 'Recycle Bin',
86
55
  description: 'Recycle Bin',
87
56
  type: 'trashFolder',
88
57
  version: 1,
89
- createdBy: exports.EMULATED_USER.id,
90
- modifiedBy: exports.EMULATED_USER.id,
91
- creationTimeStamp: exports.EMULATED_NOW,
92
- modifiedTimeStamp: exports.EMULATED_NOW,
58
+ createdBy: ids_js_1.EMULATED_USER.id,
59
+ modifiedBy: ids_js_1.EMULATED_USER.id,
60
+ creationTimeStamp: ids_js_1.EMULATED_NOW,
61
+ modifiedTimeStamp: ids_js_1.EMULATED_NOW,
93
62
  memberCount: 0,
94
63
  parentFolderUri: '',
95
64
  properties: { allowMove: 'false' },
96
65
  links: linksFor(`/folders/folders/${id}`)
97
66
  };
98
67
  };
99
- const requireDrive = (services) => {
100
- if (!services.drive)
101
- throw new types_js_1.ApiError(501, 'This host has no drive, so it cannot answer a folder operation.');
102
- return services.drive;
103
- };
104
68
  const pathFromQuery = (request) => {
105
69
  const path = request.query?.path;
106
70
  if (!path)
107
71
  throw new types_js_1.ApiError(400, 'The path parameter is required.');
108
- return path;
72
+ return (0, ids_js_1.normalisePath)(path);
109
73
  };
110
74
  /** The recycle-bin alias the emulator answers, which is also a valid parent. */
111
75
  const RECYCLE_BIN_ALIAS = '/folders/folders/@myRecycleBin';
112
76
  const isRecycleBin = (uri) => !!uri &&
113
- (uri === RECYCLE_BIN_ALIAS || uri.endsWith(`/${(0, exports.idFor)('@myRecycleBin')}`));
77
+ (uri === RECYCLE_BIN_ALIAS || uri.endsWith(`/${(0, ids_js_1.idFor)('@myRecycleBin')}`));
114
78
  /**
115
79
  * The path a folder id stands for, found by walking the drive.
116
80
  *
@@ -121,7 +85,7 @@ const isRecycleBin = (uri) => !!uri &&
121
85
  */
122
86
  const pathForId = async (drive, id) => {
123
87
  const walk = (node) => {
124
- if (node.isFolder && (0, exports.idFor)(node.relativePath) === id)
88
+ if (node.isFolder && (0, ids_js_1.idFor)(node.relativePath) === id)
125
89
  return node.relativePath;
126
90
  for (const child of node.children) {
127
91
  const hit = walk(child);
@@ -141,12 +105,12 @@ exports.VIYA_HANDLERS = {
141
105
  'GET /identities/users/@currentUser': async ({ services, request }) => {
142
106
  const subject = request.subject ??
143
107
  (await services.identity?.authenticate(request.token));
144
- const id = subject?.userId ?? exports.EMULATED_USER.id;
108
+ const id = subject?.userId ?? ids_js_1.EMULATED_USER.id;
145
109
  return {
146
110
  status: 200,
147
111
  body: {
148
112
  id,
149
- name: subject?.userId ?? exports.EMULATED_USER.name,
113
+ name: subject?.userId ?? ids_js_1.EMULATED_USER.name,
150
114
  providerId: 'sas',
151
115
  state: 'active',
152
116
  version: 1,
@@ -180,7 +144,7 @@ exports.VIYA_HANDLERS = {
180
144
  }),
181
145
  'GET /folders/folders/@item': async ({ services, request }) => ({
182
146
  status: 200,
183
- body: await folderBody(requireDrive(services), pathFromQuery(request))
147
+ body: await folderBody((0, ports_js_1.requireDrive)(services), pathFromQuery(request))
184
148
  }),
185
149
  'GET /folders/folders/@myRecycleBin': async () => ({
186
150
  status: 200,
@@ -188,20 +152,20 @@ exports.VIYA_HANDLERS = {
188
152
  }),
189
153
  'GET /folders/folders/{}': async ({ services, params }) => {
190
154
  // the bin is addressed by id too, and it is not in the drive's tree
191
- if (params.id === (0, exports.idFor)('@myRecycleBin'))
155
+ if (params.id === (0, ids_js_1.idFor)('@myRecycleBin'))
192
156
  return { status: 200, body: recycleBin() };
193
- const drive = requireDrive(services);
157
+ const drive = (0, ports_js_1.requireDrive)(services);
194
158
  return {
195
159
  status: 200,
196
160
  body: await folderBody(drive, await pathForId(drive, params.id))
197
161
  };
198
162
  },
199
163
  'GET /folders/folders/{}/members': async ({ services, params, request }) => {
200
- const drive = requireDrive(services);
164
+ const drive = (0, ports_js_1.requireDrive)(services);
201
165
  const limit = Number(request.query?.limit ?? 0) || 0;
202
166
  // the bin is not a folder in the drive, and its own body advertises this
203
167
  // link - so a client following the answer it just received must not 404
204
- if (params.id === (0, exports.idFor)('@myRecycleBin'))
168
+ if (params.id === (0, ids_js_1.idFor)('@myRecycleBin'))
205
169
  return {
206
170
  status: 200,
207
171
  body: {
@@ -214,39 +178,39 @@ exports.VIYA_HANDLERS = {
214
178
  count: 0,
215
179
  version: 2,
216
180
  items: [],
217
- links: linksFor(`/folders/folders/${(0, exports.idFor)('@myRecycleBin')}`, true)
181
+ links: linksFor(`/folders/folders/${(0, ids_js_1.idFor)('@myRecycleBin')}`, true)
218
182
  }
219
183
  };
220
184
  const path = await pathForId(drive, params.id);
221
185
  const listing = await drive.list(path);
222
186
  const items = [
223
187
  ...listing.folders.map((name) => ({
224
- id: (0, exports.idFor)(`${path}/${name}`.replace(/\/{2,}/g, '/')),
188
+ id: (0, ids_js_1.idFor)(`${path}/${name}`.replace(/\/{2,}/g, '/')),
225
189
  name,
226
190
  type: 'folder',
227
191
  version: 1,
228
- createdBy: exports.EMULATED_USER.id,
229
- modifiedBy: exports.EMULATED_USER.id,
230
- creationTimeStamp: exports.EMULATED_NOW,
231
- modifiedTimeStamp: exports.EMULATED_NOW,
232
- parentFolderUri: `/folders/folders/${(0, exports.idFor)(path)}`,
192
+ createdBy: ids_js_1.EMULATED_USER.id,
193
+ modifiedBy: ids_js_1.EMULATED_USER.id,
194
+ creationTimeStamp: ids_js_1.EMULATED_NOW,
195
+ modifiedTimeStamp: ids_js_1.EMULATED_NOW,
196
+ parentFolderUri: `/folders/folders/${(0, ids_js_1.idFor)(path)}`,
233
197
  uri: `${path}/${name}`.replace(/\/{2,}/g, '/'),
234
- links: linksFor(`/folders/folders/${(0, exports.idFor)(`${path}/${name}`.replace(/\/{2,}/g, '/'))}`)
198
+ links: linksFor(`/folders/folders/${(0, ids_js_1.idFor)(`${path}/${name}`.replace(/\/{2,}/g, '/'))}`)
235
199
  })),
236
200
  ...listing.files.map((name) => ({
237
- id: (0, exports.idFor)(`${path}/${name}`.replace(/\/{2,}/g, '/'), 'file'),
201
+ id: (0, ids_js_1.idFor)(`${path}/${name}`.replace(/\/{2,}/g, '/'), 'file'),
238
202
  name,
239
203
  type: 'file',
240
204
  version: 1,
241
205
  contentType: 'text/plain',
242
- createdBy: exports.EMULATED_USER.id,
243
- modifiedBy: exports.EMULATED_USER.id,
244
- creationTimeStamp: exports.EMULATED_NOW,
245
- modifiedTimeStamp: exports.EMULATED_NOW,
246
- parentFolderUri: `/folders/folders/${(0, exports.idFor)(path)}`,
247
- added: exports.EMULATED_NOW,
206
+ createdBy: ids_js_1.EMULATED_USER.id,
207
+ modifiedBy: ids_js_1.EMULATED_USER.id,
208
+ creationTimeStamp: ids_js_1.EMULATED_NOW,
209
+ modifiedTimeStamp: ids_js_1.EMULATED_NOW,
210
+ parentFolderUri: `/folders/folders/${(0, ids_js_1.idFor)(path)}`,
211
+ added: ids_js_1.EMULATED_NOW,
248
212
  uri: `${path}/${name}`.replace(/\/{2,}/g, '/'),
249
- links: linksFor(`/files/files/${(0, exports.idFor)(`${path}/${name}`.replace(/\/{2,}/g, '/'), 'file')}`)
213
+ links: linksFor(`/files/files/${(0, ids_js_1.idFor)(`${path}/${name}`.replace(/\/{2,}/g, '/'), 'file')}`)
250
214
  }))
251
215
  ];
252
216
  const page = limit > 0 ? items.slice(0, limit) : items;
@@ -262,12 +226,12 @@ exports.VIYA_HANDLERS = {
262
226
  count: page.length,
263
227
  version: 2,
264
228
  items: page,
265
- links: linksFor(`/folders/folders/${(0, exports.idFor)(path)}`, true)
229
+ links: linksFor(`/folders/folders/${(0, ids_js_1.idFor)(path)}`, true)
266
230
  }
267
231
  };
268
232
  },
269
233
  'POST /folders/folders': async ({ services, request }) => {
270
- const drive = requireDrive(services);
234
+ const drive = (0, ports_js_1.requireDrive)(services);
271
235
  const body = (request.body ?? {});
272
236
  if (!body.name)
273
237
  throw new types_js_1.ApiError(400, 'A folder name is required.');
@@ -277,13 +241,13 @@ exports.VIYA_HANDLERS = {
277
241
  const parent = parentUri
278
242
  ? await pathForId(drive, String(parentUri).split('/').pop())
279
243
  : '/';
280
- const path = `${parent}/${body.name}`.replace(/\/{2,}/g, '/');
244
+ const path = (0, ids_js_1.normalisePath)(`${parent}/${body.name}`);
281
245
  await drive.mkdir(path);
282
246
  return { status: 201, body: await folderBody(drive, path) };
283
247
  },
284
248
  'PATCH /folders/folders/{}': async ({ services, request, params }) => {
285
- const drive = requireDrive(services);
286
- if (params.id === (0, exports.idFor)('@myRecycleBin'))
249
+ const drive = (0, ports_js_1.requireDrive)(services);
250
+ if (params.id === (0, ids_js_1.idFor)('@myRecycleBin'))
287
251
  throw new types_js_1.ApiError(400, 'The recycle bin cannot be moved or renamed.');
288
252
  const path = await pathForId(drive, params.id);
289
253
  const body = (request.body ?? {});
@@ -309,9 +273,11 @@ exports.VIYA_HANDLERS = {
309
273
  : body.parentFolderUri === ''
310
274
  ? '/'
311
275
  : await pathForId(drive, body.parentFolderUri.split('/').pop());
312
- const target = `${parent}/${name}`.replace(/\/{2,}/g, '/');
276
+ const target = (0, ids_js_1.normalisePath)(`${parent}/${name}`);
313
277
  if (target !== path)
314
278
  await drive.rename(path, target);
315
279
  return { status: 200, body: await folderBody(drive, target) };
316
- }
280
+ },
281
+ ...compute_js_1.COMPUTE_HANDLERS,
282
+ ...files_js_1.FILE_HANDLERS
317
283
  };
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.estateFor = exports.EmulatedEstate = exports.logFor = void 0;
4
+ /**
5
+ * The emulated compute estate: sessions, jobs and the logs generated for them.
6
+ *
7
+ * A session is a handle a client keeps and asks about later, so it lives in the
8
+ * process that issued it - the way a real compute server's does - and it survives
9
+ * as long as the emulator does. Ids are a function of the seed and a counter
10
+ * rather than a random uuid: a session id that changes between runs would break
11
+ * every fixture that names one, which is the same rule as a folder id.
12
+ *
13
+ * Nothing here executes SAS. The engine is not present, and a log that claimed to
14
+ * be output would be a lie the first time somebody read it. The log echoes what
15
+ * was submitted and states, in the log itself, that it is generated - so a client
16
+ * that parses for NOTEs still gets a well-formed log, and a person reading it is
17
+ * not misled about what ran.
18
+ */
19
+ const seed_js_1 = require("./seed.js");
20
+ /**
21
+ * The generated log for one program.
22
+ *
23
+ * Deterministic in (seed, code): the same program on the same estate answers the
24
+ * same lines, so a test can assert a log and a screenshot stays true. The numbers
25
+ * are drawn rather than fixed so that two estates do not look identical, and the
26
+ * generator is re-seeded from the code for each job so that one job's log does not
27
+ * depend on how many jobs ran before it.
28
+ */
29
+ const logFor = (seed, program) => {
30
+ const code = Array.isArray(program) ? program.join('\n') : program;
31
+ // seeded from the program's TEXT, not its length: two programs of the same
32
+ // length are two programs, and a fixture that names the numbers would be
33
+ // right for both of them otherwise
34
+ const next = (0, seed_js_1.generator)(seed ^ (0, seed_js_1.hash)(`code:${code}`));
35
+ const rows = (0, seed_js_1.drawInt)(next, 900) + 100;
36
+ const seconds = ((0, seed_js_1.drawInt)(next, 90) + 10) / 100;
37
+ const lines = code
38
+ .split('\n')
39
+ .map((line, index) => `${String(index + 1).padStart(3, ' ')} ${line}`);
40
+ return [
41
+ 'NOTE: Emulated compute engine - this log is generated, not produced by SAS.',
42
+ 'NOTE: No library was touched: the emulated engine has none.',
43
+ ...lines,
44
+ `NOTE: The data set WORK.EMULATED has ${rows} observations and 3 variables.`,
45
+ `NOTE: DATA statement used (Total process time):`,
46
+ `NOTE: real time ${seconds.toFixed(2)} seconds`,
47
+ `NOTE: user cpu time ${(seconds / 2).toFixed(2)} seconds`,
48
+ `NOTE: ${(0, seed_js_1.drawFrom)(next, ['The emulated run completed.', 'Emulation complete - no SAS was executed.'])}`
49
+ ];
50
+ };
51
+ exports.logFor = logFor;
52
+ /**
53
+ * The sessions one estate holds.
54
+ *
55
+ * Keyed by seed, so two emulated estates in one process - a test that runs two
56
+ * targets - do not share a session namespace.
57
+ */
58
+ class EmulatedEstate {
59
+ constructor(seed) {
60
+ this.seed = seed;
61
+ this.sessions = new Map();
62
+ this.created = 0;
63
+ }
64
+ /** A new session: deterministic id, no jobs. */
65
+ create() {
66
+ const session = {
67
+ id: `emulated-${this.seed.toString(16)}-ses${String(this.created++).padStart(4, '0')}`,
68
+ createdAt: new Date().toISOString(),
69
+ jobs: new Map(),
70
+ submitted: 0
71
+ };
72
+ this.sessions.set(session.id, session);
73
+ return session;
74
+ }
75
+ session(id) {
76
+ return this.sessions.get(id);
77
+ }
78
+ remove(id) {
79
+ return this.sessions.delete(id);
80
+ }
81
+ /** A job accepted into a session, with the log the emulator generated for it. */
82
+ submit(session, job) {
83
+ const id = `${session.id}-job${String(session.submitted++).padStart(4, '0')}`;
84
+ const code = job.code ?? '';
85
+ const submitted = {
86
+ id,
87
+ name: job.name ?? id,
88
+ // the log is a function of the seed and the program alone, so the same
89
+ // program answers the same lines whatever session it was submitted in
90
+ log: (0, exports.logFor)(this.seed, code),
91
+ state: 'completed',
92
+ // the real clock, unlike a folder's: a client computes a session's age
93
+ // from this stamp and expires it, so a fixed instant in the past is a
94
+ // session that is born expired
95
+ creationTimeStamp: new Date().toISOString(),
96
+ completedTimeStamp: new Date().toISOString(),
97
+ sessionId: session.id
98
+ };
99
+ session.jobs.set(id, submitted);
100
+ return submitted;
101
+ }
102
+ }
103
+ exports.EmulatedEstate = EmulatedEstate;
104
+ /** One estate per seed, for the life of the process. */
105
+ const estates = new Map();
106
+ const estateFor = (seed) => {
107
+ const existing = estates.get(seed);
108
+ if (existing)
109
+ return existing;
110
+ const estate = new EmulatedEstate(seed);
111
+ estates.set(seed, estate);
112
+ return estate;
113
+ };
114
+ exports.estateFor = estateFor;
@@ -2,6 +2,7 @@ import type { DriveService } from '../drive/service.js';
2
2
  import type { IdentityService } from '../identity/service.js';
3
3
  import type { RecordService } from '../identity/records.js';
4
4
  import type { SessionService } from '../session/service.js';
5
+ import type { ViyaSeedSettings } from '../viya/seed.js';
5
6
  import type { RuntimeService } from '../runtime/service.js';
6
7
  import type { AppStreamService } from '../appstream/service.js';
7
8
  import type { CodeService } from '../code/service.js';
@@ -94,6 +95,15 @@ export interface Services {
94
95
  * answers 501 for these four, naming the capability.
95
96
  */
96
97
  session?: SessionService;
98
+ /**
99
+ * The emulated Viya estate this host mounts, when it mounts one.
100
+ *
101
+ * Absent, the emulated answers fall back to one shared seed. The address is what
102
+ * identifies an estate, so `serverUrl` is the seed unless `seed` overrides it -
103
+ * which a host does when the port moves between runs or the estate answers on a
104
+ * second hostname.
105
+ */
106
+ viya?: ViyaSeedSettings;
97
107
  /**
98
108
  * The execute and trigger routes, over the host's runner. Absent, they answer
99
109
  * 501: the package can decide everything about a run except performing it.
@@ -1 +1 @@
1
- {"version":3,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;IACH,SAAS,CAAC,EAAE,gBAAgB,CAAA;CAC7B;AAmFD,eAAO,MAAM,QAAQ,GACnB,UAAU,QAAQ,EAClB,SAAS,MAAM,EACf,UAAS,UAAe,KACvB,OAAO,CAAC,WAAW,CAgxBrB,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,SAAS,GAAI,SAAS,MAAM,KAAG,QAO3C,CAAA;AAED,0DAA0D;AAC1D,eAAO,MAAM,cAAc,EAAE,MAAM,EA+DlC,CAAA"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * The compute family: contexts, sessions, jobs and the logs generated for them.
3
+ *
4
+ * These are the operations a `serverType=SASVIYA` application needs before it can
5
+ * do anything: find a context, start a session, submit a program, poll it, read
6
+ * its log. The emulator answers all of them from `EmulatedEstate` - this process -
7
+ * because there is no SAS engine to reach for in a browser and no reason to reach
8
+ * for one here.
9
+ *
10
+ * The context is the one place the emulator answers the question it was asked
11
+ * rather than one it chose: a client names the context it wants by filter and the
12
+ * emulated estate has exactly one, under that name. Its id does not move with the
13
+ * name, so a session can be created for the id the list returned.
14
+ */
15
+ import type { ApiResponse, Services } from '../host/dispatch.js';
16
+ /** The name the emulator answers when a client asks for no particular context. */
17
+ export declare const DEFAULT_CONTEXT_NAME = "Emulated Compute Context";
18
+ /** The one context id this estate mints, whatever name it is asked for. */
19
+ export declare const EMULATED_CONTEXT_ID: string;
20
+ /**
21
+ * The context name a client asked for.
22
+ *
23
+ * The adapter filters by name (`filter=eq(name,'X')`), so the answer is the one
24
+ * emulated context under the requested name. A second estate is not something an
25
+ * emulator can have, and an empty list would fail a client that has nothing wrong
26
+ * with it.
27
+ */
28
+ export declare const contextNameFrom: (filter: string | undefined) => string;
29
+ export declare const COMPUTE_HANDLERS: Record<string, (context: {
30
+ services: Services;
31
+ request: {
32
+ query?: Record<string, string | undefined>;
33
+ body?: unknown;
34
+ token?: string;
35
+ subject?: unknown;
36
+ };
37
+ params: Record<string, string>;
38
+ }) => Promise<ApiResponse>>;
39
+ //# sourceMappingURL=compute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compute.d.ts","sourceRoot":"","sources":["../../../src/viya/compute.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAOhE,kFAAkF;AAClF,eAAO,MAAM,oBAAoB,6BAA6B,CAAA;AAE9D,2EAA2E;AAC3E,eAAO,MAAM,mBAAmB,QAAuC,CAAA;AA+CvE;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,MAAM,GAAG,SAAS,KAAG,MAM5D,CAAA;AA6GD,eAAO,MAAM,gBAAgB,EAAE,MAAM,CACnC,MAAM,EACN,CAAC,OAAO,EAAE;IACR,QAAQ,EAAE,QAAQ,CAAA;IAClB,OAAO,EAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;QAC1C,IAAI,CAAC,EAAE,OAAO,CAAA;QACd,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,OAAO,CAAC,EAAE,OAAO,CAAA;KAClB,CAAA;IACD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC/B,KAAK,OAAO,CAAC,WAAW,CAAC,CAwH3B,CAAA"}