@sasjs/api 0.22.0 → 0.23.1

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/build/browser.js CHANGED
@@ -1,4 +1,4 @@
1
- /* @sasjs/api 0.22.0 - the SASjs Server API, for a service worker. https://github.com/sasjs/api */
1
+ /* @sasjs/api 0.23.1 - the SASjs Server API, for a service worker. https://github.com/sasjs/api */
2
2
  "use strict";
3
3
  var SASjsApi = (() => {
4
4
  var __defProp = Object.defineProperty;
@@ -346,10 +346,14 @@ var SASjsApi = (() => {
346
346
  );
347
347
  }
348
348
  for (const file of listing.files) {
349
+ const relativePath = path === "/" ? "/" + file : path + "/" + file;
350
+ const stat = await store.stat(relativePath);
349
351
  children.push({
350
352
  name: file,
351
- relativePath: path === "/" ? "/" + file : path + "/" + file,
353
+ relativePath,
352
354
  isFolder: false,
355
+ ...stat.modified ? { modified: stat.modified } : {},
356
+ ...stat.created ? { created: stat.created } : {},
353
357
  children: []
354
358
  });
355
359
  }
@@ -470,6 +474,14 @@ var SASjsApi = (() => {
470
474
  constructor(seed = {}) {
471
475
  this.files = /* @__PURE__ */ new Map();
472
476
  this.folders = /* @__PURE__ */ new Set(["/"]);
477
+ /**
478
+ * When each entry was first written and last written, ISO strings.
479
+ *
480
+ * A Map has no clock of its own, so the store keeps one: a seeded drive is
481
+ * created when the store is, and a write moves `modified` while `created`
482
+ * stays. A host with real file metadata reports its own instead.
483
+ */
484
+ this.times = /* @__PURE__ */ new Map();
473
485
  for (const [path, contents] of Object.entries(seed)) {
474
486
  this.putSync(path, contents);
475
487
  }
@@ -486,6 +498,12 @@ var SASjsApi = (() => {
486
498
  path,
487
499
  typeof contents === "string" ? contents : contents.slice()
488
500
  );
501
+ const now = (/* @__PURE__ */ new Date()).toISOString();
502
+ const existing = this.times.get(path);
503
+ this.times.set(path, {
504
+ created: existing?.created ?? now,
505
+ modified: now
506
+ });
489
507
  }
490
508
  mkdirpSync(path) {
491
509
  const parts = path.split("/").filter(Boolean);
@@ -527,9 +545,11 @@ var SASjsApi = (() => {
527
545
  return { directory: true, size: 0 };
528
546
  const contents = this.files.get(path);
529
547
  if (contents === void 0) throw new ApiError(404, `File doesn't exist.`);
548
+ const times = this.times.get(path);
530
549
  return {
531
550
  directory: false,
532
- size: typeof contents === "string" ? contents.length : contents.length
551
+ size: typeof contents === "string" ? contents.length : contents.length,
552
+ ...times ? { modified: times.modified, created: times.created } : {}
533
553
  };
534
554
  }
535
555
  async list(path) {
@@ -5673,7 +5693,10 @@ var SASjsApi = (() => {
5673
5693
  request: { query: { _folderPath: "/data" } },
5674
5694
  expect: {
5675
5695
  status: 200,
5676
- body: {
5696
+ // Partial, because a file's `created` and `modified` are the host's
5697
+ // clock rather than the contract: the shape is asserted, the timestamps
5698
+ // are whatever the host that ran the case says they are.
5699
+ partial: {
5677
5700
  status: "success",
5678
5701
  tree: {
5679
5702
  name: "data",
@@ -285,7 +285,10 @@ exports.DRIVE_CORPUS = [
285
285
  request: { query: { _folderPath: '/data' } },
286
286
  expect: {
287
287
  status: 200,
288
- body: {
288
+ // Partial, because a file's `created` and `modified` are the host's
289
+ // clock rather than the contract: the shape is asserted, the timestamps
290
+ // are whatever the host that ran the case says they are.
291
+ partial: {
289
292
  status: 'success',
290
293
  tree: {
291
294
  name: 'data',
@@ -7,6 +7,14 @@ class MemoryDriveStore {
7
7
  constructor(seed = {}) {
8
8
  this.files = new Map();
9
9
  this.folders = new Set(['/']);
10
+ /**
11
+ * When each entry was first written and last written, ISO strings.
12
+ *
13
+ * A Map has no clock of its own, so the store keeps one: a seeded drive is
14
+ * created when the store is, and a write moves `modified` while `created`
15
+ * stays. A host with real file metadata reports its own instead.
16
+ */
17
+ this.times = new Map();
10
18
  for (const [path, contents] of Object.entries(seed)) {
11
19
  this.putSync(path, contents);
12
20
  }
@@ -21,6 +29,12 @@ class MemoryDriveStore {
21
29
  putSync(path, contents) {
22
30
  this.mkdirpSync((0, paths_js_1.dirname)(path));
23
31
  this.files.set(path, typeof contents === 'string' ? contents : contents.slice());
32
+ const now = new Date().toISOString();
33
+ const existing = this.times.get(path);
34
+ this.times.set(path, {
35
+ created: existing?.created ?? now,
36
+ modified: now
37
+ });
24
38
  }
25
39
  mkdirpSync(path) {
26
40
  const parts = path.split('/').filter(Boolean);
@@ -68,9 +82,11 @@ class MemoryDriveStore {
68
82
  const contents = this.files.get(path);
69
83
  if (contents === undefined)
70
84
  throw new types_js_1.ApiError(404, `File doesn't exist.`);
85
+ const times = this.times.get(path);
71
86
  return {
72
87
  directory: false,
73
- size: typeof contents === 'string' ? contents.length : contents.length
88
+ size: typeof contents === 'string' ? contents.length : contents.length,
89
+ ...(times ? { modified: times.modified, created: times.created } : {})
74
90
  };
75
91
  }
76
92
  async list(path) {
@@ -31,10 +31,16 @@ const createDriveService = (store) => {
31
31
  children.push(await treeOf(path === '/' ? '/' + folder : path + '/' + folder));
32
32
  }
33
33
  for (const file of listing.files) {
34
+ const relativePath = path === '/' ? '/' + file : path + '/' + file;
35
+ // One stat per file: the dates a client sorts or shows are the host's,
36
+ // and a store that reports none simply omits them.
37
+ const stat = await store.stat(relativePath);
34
38
  children.push({
35
39
  name: file,
36
- relativePath: path === '/' ? '/' + file : path + '/' + file,
40
+ relativePath,
37
41
  isFolder: false,
42
+ ...(stat.modified ? { modified: stat.modified } : {}),
43
+ ...(stat.created ? { created: stat.created } : {}),
38
44
  children: []
39
45
  });
40
46
  }
@@ -1 +1 @@
1
- {"version":3,"file":"drive.d.ts","sourceRoot":"","sources":["../../../src/corpus/drive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAE7D,MAAM,WAAW,UAAU;IACzB,6CAA6C;IAC7C,EAAE,EAAE,MAAM,CAAA;IACV,kEAAkE;IAClE,KAAK,EAAE,MAAM,CAAA;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
  status: 200,
285
- body: {
285
+ // Partial, because a file's `created` and `modified` are the host's
286
+ // clock rather than the contract: the shape is asserted, the timestamps
287
+ // are whatever the host that ran the case says they are.
288
+ partial: {
286
289
  status: 'success',
287
290
  tree: {
288
291
  name: 'data',
@@ -12,6 +12,14 @@ type Entry = string | Uint8Array;
12
12
  export declare class MemoryDriveStore implements DriveStore {
13
13
  private files;
14
14
  private folders;
15
+ /**
16
+ * When each entry was first written and last written, ISO strings.
17
+ *
18
+ * A Map has no clock of its own, so the store keeps one: a seeded drive is
19
+ * created when the store is, and a write moves `modified` while `created`
20
+ * stays. A host with real file metadata reports its own instead.
21
+ */
22
+ private times;
15
23
  constructor(seed?: Record<string, Entry>);
16
24
  /** Everything on the drive, for a snapshot or an assertion. */
17
25
  dump(): Record<string, Entry>;
@@ -24,6 +32,8 @@ export declare class MemoryDriveStore implements DriveStore {
24
32
  stat(path: string): Promise<{
25
33
  directory: boolean;
26
34
  size: number;
35
+ modified?: string;
36
+ created?: string;
27
37
  }>;
28
38
  list(path: string): Promise<{
29
39
  files: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"memory-store.d.ts","sourceRoot":"","sources":["../../../src/drive/memory-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAI7C,KAAK,KAAK,GAAG,MAAM,GAAG,UAAU,CAAA;AAEhC,qBAAa,gBAAiB,YAAW,UAAU;IACjD,OAAO,CAAC,KAAK,CAA2B;IACxC,OAAO,CAAC,OAAO,CAAyB;gBAE5B,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAM;IAM5C,+DAA+D;IAC/D,IAAI,IAAI,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC;IAM7B,OAAO,CAAC,OAAO;IAQf,OAAO,CAAC,UAAU;IASlB,OAAO,CAAC,QAAQ;IAiBV,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,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I,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IAMlC,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC;IAInD,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAItC,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;QAChC,SAAS,EAAE,OAAO,CAAA;QAClB,IAAI,EAAE,MAAM,CAAA;QACZ,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,OAAO,CAAC,EAAE,MAAM,CAAA;KACjB,CAAC;IAgBI,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,EAAE,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IAInE,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAInC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAYnC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CA8BpD"}
@@ -4,6 +4,14 @@ export class MemoryDriveStore {
4
4
  constructor(seed = {}) {
5
5
  this.files = new Map();
6
6
  this.folders = new Set(['/']);
7
+ /**
8
+ * When each entry was first written and last written, ISO strings.
9
+ *
10
+ * A Map has no clock of its own, so the store keeps one: a seeded drive is
11
+ * created when the store is, and a write moves `modified` while `created`
12
+ * stays. A host with real file metadata reports its own instead.
13
+ */
14
+ this.times = new Map();
7
15
  for (const [path, contents] of Object.entries(seed)) {
8
16
  this.putSync(path, contents);
9
17
  }
@@ -18,6 +26,12 @@ export class MemoryDriveStore {
18
26
  putSync(path, contents) {
19
27
  this.mkdirpSync(dirname(path));
20
28
  this.files.set(path, typeof contents === 'string' ? contents : contents.slice());
29
+ const now = new Date().toISOString();
30
+ const existing = this.times.get(path);
31
+ this.times.set(path, {
32
+ created: existing?.created ?? now,
33
+ modified: now
34
+ });
21
35
  }
22
36
  mkdirpSync(path) {
23
37
  const parts = path.split('/').filter(Boolean);
@@ -65,9 +79,11 @@ export class MemoryDriveStore {
65
79
  const contents = this.files.get(path);
66
80
  if (contents === undefined)
67
81
  throw new ApiError(404, `File doesn't exist.`);
82
+ const times = this.times.get(path);
68
83
  return {
69
84
  directory: false,
70
- size: typeof contents === 'string' ? contents.length : contents.length
85
+ size: typeof contents === 'string' ? contents.length : contents.length,
86
+ ...(times ? { modified: times.modified, created: times.created } : {})
71
87
  };
72
88
  }
73
89
  async list(path) {
@@ -1 +1 @@
1
- {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/drive/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAYvD,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,SAAS,CAAA;CAClB;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,OAAO,EAAE,MAAM,EAAE,CAAA;CAClB;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,GAAG,UAAU,CAAA;IAC7B,MAAM,EAAE,OAAO,CAAA;CAChB;AAED,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,SAAS,CAAA;IACjB,IAAI,EAAE,QAAQ,CAAA;CACf;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAAA;IAChD,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAAA;IAC1C,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,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CAAA;CACf;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAAA;IAChD,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAAA;IAC1C,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC,CAAA;IAC3E,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC,CAAA;IAC7E,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAA;IAC9C,KAAK,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAA;IAC/C,KAAK,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAA;IAC/C,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAA;IAC9D,IAAI,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAAA;IAC7C;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC,CAAA;CAC5D;AAqBD,eAAO,MAAM,kBAAkB,GAAI,OAAO,UAAU,KAAG,YAiKtD,CAAA"}
@@ -28,10 +28,16 @@ export const createDriveService = (store) => {
28
28
  children.push(await treeOf(path === '/' ? '/' + folder : path + '/' + folder));
29
29
  }
30
30
  for (const file of listing.files) {
31
+ const relativePath = path === '/' ? '/' + file : path + '/' + file;
32
+ // One stat per file: the dates a client sorts or shows are the host's,
33
+ // and a store that reports none simply omits them.
34
+ const stat = await store.stat(relativePath);
31
35
  children.push({
32
36
  name: file,
33
- relativePath: path === '/' ? '/' + file : path + '/' + file,
37
+ relativePath,
34
38
  isFolder: false,
39
+ ...(stat.modified ? { modified: stat.modified } : {}),
40
+ ...(stat.created ? { created: stat.created } : {}),
35
41
  children: []
36
42
  });
37
43
  }
@@ -124,9 +124,19 @@ export interface DriveStore {
124
124
  read(path: string): Promise<string | Uint8Array>;
125
125
  write(path: string, contents: string | Uint8Array): Promise<void>;
126
126
  exists(path: string): Promise<boolean>;
127
+ /**
128
+ * What is at a path, as a host can report it.
129
+ *
130
+ * `modified` and `created` are ISO timestamps and optional: a store with no
131
+ * clock behind it (a Map seeded from a fixture) omits them rather than
132
+ * inventing a date. A host that has them - a filesystem, a browser's file
133
+ * metadata - states them, and they travel to the client on the drive tree.
134
+ */
127
135
  stat(path: string): Promise<{
128
136
  directory: boolean;
129
137
  size: number;
138
+ modified?: string;
139
+ created?: string;
130
140
  }>;
131
141
  list(path: string): Promise<{
132
142
  files: string[];
@@ -141,6 +151,10 @@ export interface TreeNode {
141
151
  name: string;
142
152
  relativePath: string;
143
153
  isFolder: boolean;
154
+ /** ISO timestamp of the last write, when the host can report one. */
155
+ modified?: string;
156
+ /** ISO timestamp of creation, when the host can report one. */
157
+ created?: string;
144
158
  children: TreeNode[];
145
159
  }
146
160
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;GAIG;AACH,qBAAa,QAAS,SAAQ,KAAK;IAK/B,QAAQ,CAAC,MAAM,EAAE,MAAM;IAEvB;;;;;;;OAOG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO;IAdzB,wEAAwE;IACxE,QAAQ,CAAC,QAAQ,QAAO;gBAGb,MAAM,EAAE,MAAM,EACvB,OAAO,EAAE,MAAM;IACf;;;;;;;OAOG;IACM,IAAI,CAAC,EAAE,OAAO,YAAA;C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CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACnC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAC9C;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,MAAM,CAAA;IACpB,QAAQ,EAAE,OAAO,CAAA;IACjB,qEAAqE;IACrE,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,+DAA+D;IAC/D,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,QAAQ,EAAE,CAAA;CACrB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sasjs/api",
3
- "version": "0.22.0",
3
+ "version": "0.23.1",
4
4
  "description": "The SASjs Server API, described once - a generated route table, the services behind it, and the conformance corpus both hosts run",
5
5
  "license": "MIT",
6
6
  "author": "SASjs",
@@ -68,6 +68,6 @@
68
68
  "minimatch": "11.0.4"
69
69
  },
70
70
  "dependencies": {
71
- "@sasjs/lint": "5.0.0"
71
+ "@sasjs/lint": "^5.1.0"
72
72
  }
73
73
  }