@fnndsc/cumin 3.30.6 → 3.31.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 (161) hide show
  1. package/dist/cache/checkpointWatch.d.ts +36 -0
  2. package/dist/cache/checkpointWatch.js +83 -0
  3. package/dist/cache/checkpointWatch.js.map +1 -0
  4. package/dist/cache/index.d.ts +1 -1
  5. package/dist/cache/index.js +4 -1
  6. package/dist/cache/index.js.map +1 -1
  7. package/dist/cache/listCache.d.ts +54 -2
  8. package/dist/cache/listCache.js +120 -24
  9. package/dist/cache/listCache.js.map +1 -1
  10. package/dist/cache/listCheckpoint.d.ts +5 -8
  11. package/dist/cache/listCheckpoint.js +17 -28
  12. package/dist/cache/listCheckpoint.js.map +1 -1
  13. package/dist/cache/listingInvalidation.js +11 -6
  14. package/dist/cache/listingInvalidation.js.map +1 -1
  15. package/dist/cache/procCache.d.ts +11 -0
  16. package/dist/cache/procCache.js +26 -1
  17. package/dist/cache/procCache.js.map +1 -1
  18. package/dist/cache/procCheckpoint.d.ts +11 -6
  19. package/dist/cache/procCheckpoint.js +280 -86
  20. package/dist/cache/procCheckpoint.js.map +1 -1
  21. package/dist/cache/queryIndex.d.ts +11 -0
  22. package/dist/cache/queryIndex.js +38 -2
  23. package/dist/cache/queryIndex.js.map +1 -1
  24. package/dist/cache/queryIndexCheckpoint.d.ts +32 -0
  25. package/dist/cache/queryIndexCheckpoint.js +180 -30
  26. package/dist/cache/queryIndexCheckpoint.js.map +1 -1
  27. package/dist/chrisapi/adapter.d.ts +266 -37
  28. package/dist/chrisapi/adapter.js +577 -116
  29. package/dist/chrisapi/adapter.js.map +1 -1
  30. package/dist/chrisapi/contract.d.ts +20 -20
  31. package/dist/chrisapi/contract.js +213 -60
  32. package/dist/chrisapi/contract.js.map +1 -1
  33. package/dist/chrisapi/cubeRequest.d.ts +198 -0
  34. package/dist/chrisapi/cubeRequest.js +345 -0
  35. package/dist/chrisapi/cubeRequest.js.map +1 -0
  36. package/dist/chrisapi/shape.d.ts +186 -0
  37. package/dist/chrisapi/shape.js +274 -0
  38. package/dist/chrisapi/shape.js.map +1 -0
  39. package/dist/cli.js +2 -1
  40. package/dist/cli.js.map +1 -1
  41. package/dist/compute/computeResources.d.ts +3 -0
  42. package/dist/compute/computeResources.js +5 -3
  43. package/dist/compute/computeResources.js.map +1 -1
  44. package/dist/config/config.d.ts +14 -0
  45. package/dist/config/config.js +6 -3
  46. package/dist/config/config.js.map +1 -1
  47. package/dist/connect/chrisConnection.d.ts +116 -6
  48. package/dist/connect/chrisConnection.js +418 -74
  49. package/dist/connect/chrisConnection.js.map +1 -1
  50. package/dist/connect/identityEpoch.d.ts +263 -0
  51. package/dist/connect/identityEpoch.js +414 -0
  52. package/dist/connect/identityEpoch.js.map +1 -0
  53. package/dist/connect/loginFailure.js +39 -22
  54. package/dist/connect/loginFailure.js.map +1 -1
  55. package/dist/context/chrisContext.js +36 -30
  56. package/dist/context/chrisContext.js.map +1 -1
  57. package/dist/error/errorStack.d.ts +1 -1
  58. package/dist/error/errorStack.js +1 -2
  59. package/dist/error/errorStack.js.map +1 -1
  60. package/dist/feeds/chrisAccess.d.ts +7 -2
  61. package/dist/feeds/chrisAccess.js +20 -7
  62. package/dist/feeds/chrisAccess.js.map +1 -1
  63. package/dist/feeds/chrisFeed.d.ts +8 -10
  64. package/dist/feeds/chrisFeed.js +27 -57
  65. package/dist/feeds/chrisFeed.js.map +1 -1
  66. package/dist/feeds/chrisTags.d.ts +1 -1
  67. package/dist/feeds/chrisTags.js +66 -24
  68. package/dist/feeds/chrisTags.js.map +1 -1
  69. package/dist/filebrowser/chrisFileBrowser.d.ts +0 -1
  70. package/dist/filebrowser/chrisFileBrowser.js +3 -5
  71. package/dist/filebrowser/chrisFileBrowser.js.map +1 -1
  72. package/dist/filebrowser/chrisFiles.d.ts +0 -1
  73. package/dist/filebrowser/chrisFiles.js +3 -4
  74. package/dist/filebrowser/chrisFiles.js.map +1 -1
  75. package/dist/filebrowser/chrisPACS.d.ts +4 -4
  76. package/dist/filebrowser/chrisPACS.js +10 -33
  77. package/dist/filebrowser/chrisPACS.js.map +1 -1
  78. package/dist/filebrowser/chrisPipeline.js +10 -45
  79. package/dist/filebrowser/chrisPipeline.js.map +1 -1
  80. package/dist/groups/chrisGroups.d.ts +3 -0
  81. package/dist/groups/chrisGroups.js +20 -8
  82. package/dist/groups/chrisGroups.js.map +1 -1
  83. package/dist/index.d.ts +6 -8
  84. package/dist/index.js +17 -28
  85. package/dist/index.js.map +1 -1
  86. package/dist/io/chrisIO.d.ts +81 -42
  87. package/dist/io/chrisIO.js +176 -325
  88. package/dist/io/chrisIO.js.map +1 -1
  89. package/dist/io/holderClient.d.ts +248 -0
  90. package/dist/io/holderClient.js +289 -0
  91. package/dist/io/holderClient.js.map +1 -0
  92. package/dist/io/holderFolder.d.ts +151 -0
  93. package/dist/io/holderFolder.js +311 -0
  94. package/dist/io/holderFolder.js.map +1 -0
  95. package/dist/io/holderIO.d.ts +258 -0
  96. package/dist/io/holderIO.js +557 -0
  97. package/dist/io/holderIO.js.map +1 -0
  98. package/dist/io/holderRequest.d.ts +299 -0
  99. package/dist/io/holderRequest.js +447 -0
  100. package/dist/io/holderRequest.js.map +1 -0
  101. package/dist/io/holderUpload.d.ts +62 -0
  102. package/dist/io/holderUpload.js +81 -0
  103. package/dist/io/holderUpload.js.map +1 -0
  104. package/dist/io/io.d.ts +12 -0
  105. package/dist/io/io.js.map +1 -1
  106. package/dist/io/localUpload.d.ts +59 -0
  107. package/dist/io/localUpload.js +150 -0
  108. package/dist/io/localUpload.js.map +1 -0
  109. package/dist/io/node_io.d.ts +16 -0
  110. package/dist/io/node_io.js +72 -0
  111. package/dist/io/node_io.js.map +1 -1
  112. package/dist/io/streamWatch.js +2 -2
  113. package/dist/io/streamWatch.js.map +1 -1
  114. package/dist/io/transferPool.d.ts +18 -2
  115. package/dist/io/transferPool.js +32 -7
  116. package/dist/io/transferPool.js.map +1 -1
  117. package/dist/pacs/chrisPACS.d.ts +3 -9
  118. package/dist/pacs/chrisPACS.js +102 -61
  119. package/dist/pacs/chrisPACS.js.map +1 -1
  120. package/dist/pacs/queryIndexSweep.d.ts +0 -9
  121. package/dist/pacs/queryIndexSweep.js +45 -41
  122. package/dist/pacs/queryIndexSweep.js.map +1 -1
  123. package/dist/path/chrisPath.d.ts +8 -3
  124. package/dist/path/chrisPath.js +10 -9
  125. package/dist/path/chrisPath.js.map +1 -1
  126. package/dist/pipelines/chrisPipeline.d.ts +28 -5
  127. package/dist/pipelines/chrisPipeline.js +270 -94
  128. package/dist/pipelines/chrisPipeline.js.map +1 -1
  129. package/dist/pipelines/pipelineMemo.d.ts +0 -16
  130. package/dist/pipelines/pipelineMemo.js +0 -27
  131. package/dist/pipelines/pipelineMemo.js.map +1 -1
  132. package/dist/plugins/chrisPlugins.d.ts +9 -5
  133. package/dist/plugins/chrisPlugins.js +97 -58
  134. package/dist/plugins/chrisPlugins.js.map +1 -1
  135. package/dist/resources/chrisObjContext.d.ts +7 -11
  136. package/dist/resources/chrisObjContext.js +7 -42
  137. package/dist/resources/chrisObjContext.js.map +1 -1
  138. package/dist/resources/chrisResources.d.ts +186 -74
  139. package/dist/resources/chrisResources.js +421 -117
  140. package/dist/resources/chrisResources.js.map +1 -1
  141. package/dist/resources/resourceShapes.d.ts +109 -0
  142. package/dist/resources/resourceShapes.js +22 -0
  143. package/dist/resources/resourceShapes.js.map +1 -0
  144. package/dist/users/chrisUsers.d.ts +4 -1
  145. package/dist/users/chrisUsers.js +6 -2
  146. package/dist/users/chrisUsers.js.map +1 -1
  147. package/dist/utils/keypair.js +21 -10
  148. package/dist/utils/keypair.js.map +1 -1
  149. package/package.json +10 -3
  150. package/dist/activities/chrisActivity.d.ts +0 -19
  151. package/dist/activities/chrisActivity.js +0 -29
  152. package/dist/activities/chrisActivity.js.map +0 -1
  153. package/dist/jobs/chrisJob.d.ts +0 -43
  154. package/dist/jobs/chrisJob.js +0 -174
  155. package/dist/jobs/chrisJob.js.map +0 -1
  156. package/dist/jobs/index.d.ts +0 -7
  157. package/dist/jobs/index.js +0 -24
  158. package/dist/jobs/index.js.map +0 -1
  159. package/dist/jobs/jobMonitor.d.ts +0 -46
  160. package/dist/jobs/jobMonitor.js +0 -102
  161. package/dist/jobs/jobMonitor.js.map +0 -1
@@ -0,0 +1,186 @@
1
+ /**
2
+ * @file What an answer from CUBE must look like before it is used as its type.
3
+ *
4
+ * The adapter hands back what the chrisapi client returns, and until now
5
+ * handed it back as whatever type the caller named. A shape is the check
6
+ * that goes with a type: the fields the callers read without looking, each
7
+ * with the kind of value read, written once beside the type. The adapter's
8
+ * helpers take a shape and return the shape's own type, so a caller cannot
9
+ * name a type the answer was never held to.
10
+ *
11
+ * A field is one of:
12
+ *
13
+ * - required: `'number'`. It must be there and be that kind.
14
+ * - optional: `'number?'`. It may be absent; present, it must be that kind,
15
+ * and null is not that kind.
16
+ * - nullable: `'number|null'`. It must be there, and may be null.
17
+ * - optional and nullable: `'number?|null'`.
18
+ *
19
+ * The kinds are `string`, `number`, `boolean`, `object` (not null, not an
20
+ * array), `array`, `function`; for an object whose own fields are read,
21
+ * another shape; and for a list whose rows are read, `{ rows: shape }`. A
22
+ * field that is not in a shape is not checked, and is not to be read
23
+ * without a check of the caller's own.
24
+ *
25
+ * A value that fails says which field of what, and what kind was found;
26
+ * never the value.
27
+ *
28
+ * Key components:
29
+ * - shape_build: the shape of an object, from the fields that are read.
30
+ * - shape_object: the shape of a value only required to be an object.
31
+ * - shape_nullable: a shape of an answer that may be nothing.
32
+ * - rows_check: a list, each row held to a shape.
33
+ * - ShapeError: what a value that fails is refused with.
34
+ *
35
+ * Typical usage:
36
+ * ```ts
37
+ * const FEED: Shape<Feed> = shape_build<Feed>('a feed')(['id', 'number'], ['name', 'string']);
38
+ * const feed: Feed = FEED.value_check(answer);
39
+ * ```
40
+ *
41
+ * Dependencies: none.
42
+ *
43
+ * @module
44
+ */
45
+ /** The kinds a field is checked to be. */
46
+ export type FieldKind = 'string' | 'number' | 'boolean' | 'object' | 'array' | 'function';
47
+ /** A kind with its allowances: absent (`?`), null (`|null`), or both. */
48
+ export type FieldSpec<K extends string = FieldKind> = K | `${K}?` | `${K}|null` | `${K}?|null`;
49
+ /**
50
+ * What an answer was found to be, where it is not what is read.
51
+ *
52
+ * @example
53
+ * throw new ShapeError('a feed', 'id', 'missing', 'a number');
54
+ */
55
+ export declare class ShapeError extends Error {
56
+ /** What the answer is (a feed, a plugin instance). */
57
+ readonly what: string;
58
+ /** The field that is not what is read, by its path; empty for the value itself. */
59
+ readonly field: string;
60
+ /**
61
+ * @param what - What the answer is, in the words a person would use.
62
+ * @param field - The field's path; empty for the value itself.
63
+ * @param found - What was found there, as a kind.
64
+ * @param wanted - What is read there.
65
+ */
66
+ constructor(what: string, field: string, found: string, wanted: string);
67
+ }
68
+ /**
69
+ * A check that a value is a `T`, in the fields that are read.
70
+ *
71
+ * @example
72
+ * const feed: Feed = FEED.value_check(answer);
73
+ */
74
+ export interface Shape<T> {
75
+ /** What the value is, in the words a person would use. */
76
+ readonly what: string;
77
+ /**
78
+ * Checks a value.
79
+ *
80
+ * @param value - What CUBE answered.
81
+ * @param path - Where the value stands in a larger answer; empty for the answer itself.
82
+ * @param what - What the larger answer is, when this shape is a field of one.
83
+ * @returns The value, as its type.
84
+ * @throws {ShapeError} When a field that is read is not what is read.
85
+ *
86
+ * @example
87
+ * const feed: Feed = FEED.value_check(answer);
88
+ */
89
+ value_check(value: unknown, path?: string, what?: string): T;
90
+ }
91
+ /**
92
+ * A field that is a list whose rows are themselves read: an array, each row of a shape.
93
+ *
94
+ * @example
95
+ * const ITEM: Shape<Item> = shape_build<Item>('an item')(['data', { rows: FIELD }]);
96
+ */
97
+ export interface RowsOf<E> {
98
+ /** The shape of each row. */
99
+ readonly rows: Shape<E>;
100
+ }
101
+ /** A field that may be absent, and is an object of a shape when it is there. */
102
+ interface OptionalOf<S> {
103
+ /** The shape when it is there. */
104
+ readonly optional: S;
105
+ }
106
+ /** A field that may be null, and is an object of a shape when it is not. */
107
+ interface NullableOf<S> {
108
+ /** The shape when it is not null. */
109
+ readonly nullable: S;
110
+ }
111
+ /**
112
+ * The name of a shape of `T`: text, when `T` is an object that is neither a
113
+ * list nor callable, and nothing at all otherwise. A shape's check asks for
114
+ * such an object, so a shape of a list or of a function has no name it can
115
+ * be given, and does not compile.
116
+ */
117
+ export type RecordName<T> = T extends readonly unknown[] ? never : T extends (...args: never[]) => unknown ? never : string;
118
+ /** The kind a field's type is checked as, or a shape of it when it is an object. */
119
+ type KindOf<V> = V extends string ? 'string' : V extends number ? 'number' : V extends boolean ? 'boolean' : V extends (...args: never[]) => unknown ? 'function' : V extends readonly (infer E)[] ? 'array' | RowsOf<E> : V extends object ? 'object' | Shape<V> : never;
120
+ /** What may be written for a field of type `V`: its kind, with `?` only where the type allows absence and `|null` only where it allows null. */
121
+ type SpecOf<V> = unknown extends V ? FieldSpec | Shape<unknown> | OptionalOf<Shape<unknown>> | NullableOf<Shape<unknown>> | RowsOf<unknown> : KindOf<NonNullable<V>> extends infer K ? K extends string ? K | (undefined extends V ? `${K}?` : never) | (null extends V ? `${K}|null` : never) | (undefined extends V ? (null extends V ? `${K}?|null` : never) : never) : K extends Shape<unknown> ? K | (undefined extends V ? OptionalOf<K> : never) | (null extends V ? NullableOf<K> : never) : K extends RowsOf<unknown> ? K : never : never;
122
+ /** The names a type declares itself, leaving out an index signature (`[key: string]: unknown`), which names nothing. */
123
+ type DeclaredKey<T> = keyof {
124
+ [K in keyof T as string extends K ? never : number extends K ? never : K]: T[K];
125
+ } & string;
126
+ /**
127
+ * One field of a shape of `T`: the field's name as CUBE spells it, and what
128
+ * its type allows to be read there. Written as a pair so that a name with
129
+ * an underscore is a string, as it is on the wire, and not an identifier.
130
+ */
131
+ export type ShapeField<T> = {
132
+ [K in DeclaredKey<T>]: readonly [K, SpecOf<T[K]>];
133
+ }[DeclaredKey<T>];
134
+ /**
135
+ * Makes the shape of an object: a value that is an object (not null, not
136
+ * an array) whose named fields are each what is read.
137
+ *
138
+ * The type is named once, here, and must be an object's (a shape of a
139
+ * number or of text would promise a type its check, which asks for an
140
+ * object, never holds a value to). Each field's spec is held to what the
141
+ * type says of that field, so a shape cannot say `string` of a field the
142
+ * type calls a number, nor allow an absence the type does not.
143
+ *
144
+ * @param what - What the value is, in the words a person would use ("a feed").
145
+ * @returns A function from the fields, each a pair of name and spec, to the shape.
146
+ *
147
+ * @example
148
+ * const FEED: Shape<Feed> = shape_build<Feed>('a feed')(['id', 'number'], ['name', 'string?']);
149
+ */
150
+ export declare function shape_build<T extends object>(what: RecordName<T>): (...fields: ShapeField<T>[]) => Shape<T>;
151
+ /**
152
+ * The shape of a value that is only required to be an object: its fields
153
+ * are the caller's to check before reading.
154
+ *
155
+ * @param what - What the value is.
156
+ * @returns The shape.
157
+ *
158
+ * @example
159
+ * const ROW: Shape<Record<string, unknown>> = shape_object('a permission row');
160
+ */
161
+ export declare function shape_object<T extends object = Record<string, unknown>>(what: RecordName<T>): Shape<T>;
162
+ /**
163
+ * The shape of an answer that may be nothing at all: null or undefined is
164
+ * taken as null; anything else is held to the shape.
165
+ *
166
+ * @param shape - The shape of the answer when there is one.
167
+ * @returns A shape of that, or null.
168
+ *
169
+ * @example
170
+ * const FILE_OR_NONE: Shape<UserFile | null> = shape_nullable(FILE);
171
+ */
172
+ export declare function shape_nullable<T>(shape: Shape<T>): Shape<T | null>;
173
+ /**
174
+ * Checks a list: a value that is an array, each of whose rows is a `T`.
175
+ *
176
+ * @param value - What CUBE answered where a list is read.
177
+ * @param shape - The shape of a row.
178
+ * @param field - What holds the list (`data`, `items`), for the words.
179
+ * @returns The rows.
180
+ * @throws {ShapeError} When the value is not an array, or a row is not what is read; the row's place is in the field's path.
181
+ *
182
+ * @example
183
+ * const feeds: Feed[] = rows_check(page.data, FEED, 'data');
184
+ */
185
+ export declare function rows_check<T>(value: unknown, shape: Shape<T>, field: string): T[];
186
+ export {};
@@ -0,0 +1,274 @@
1
+ "use strict";
2
+ /**
3
+ * @file What an answer from CUBE must look like before it is used as its type.
4
+ *
5
+ * The adapter hands back what the chrisapi client returns, and until now
6
+ * handed it back as whatever type the caller named. A shape is the check
7
+ * that goes with a type: the fields the callers read without looking, each
8
+ * with the kind of value read, written once beside the type. The adapter's
9
+ * helpers take a shape and return the shape's own type, so a caller cannot
10
+ * name a type the answer was never held to.
11
+ *
12
+ * A field is one of:
13
+ *
14
+ * - required: `'number'`. It must be there and be that kind.
15
+ * - optional: `'number?'`. It may be absent; present, it must be that kind,
16
+ * and null is not that kind.
17
+ * - nullable: `'number|null'`. It must be there, and may be null.
18
+ * - optional and nullable: `'number?|null'`.
19
+ *
20
+ * The kinds are `string`, `number`, `boolean`, `object` (not null, not an
21
+ * array), `array`, `function`; for an object whose own fields are read,
22
+ * another shape; and for a list whose rows are read, `{ rows: shape }`. A
23
+ * field that is not in a shape is not checked, and is not to be read
24
+ * without a check of the caller's own.
25
+ *
26
+ * A value that fails says which field of what, and what kind was found;
27
+ * never the value.
28
+ *
29
+ * Key components:
30
+ * - shape_build: the shape of an object, from the fields that are read.
31
+ * - shape_object: the shape of a value only required to be an object.
32
+ * - shape_nullable: a shape of an answer that may be nothing.
33
+ * - rows_check: a list, each row held to a shape.
34
+ * - ShapeError: what a value that fails is refused with.
35
+ *
36
+ * Typical usage:
37
+ * ```ts
38
+ * const FEED: Shape<Feed> = shape_build<Feed>('a feed')(['id', 'number'], ['name', 'string']);
39
+ * const feed: Feed = FEED.value_check(answer);
40
+ * ```
41
+ *
42
+ * Dependencies: none.
43
+ *
44
+ * @module
45
+ */
46
+ Object.defineProperty(exports, "__esModule", { value: true });
47
+ exports.ShapeError = void 0;
48
+ exports.shape_build = shape_build;
49
+ exports.shape_object = shape_object;
50
+ exports.shape_nullable = shape_nullable;
51
+ exports.rows_check = rows_check;
52
+ /**
53
+ * What an answer was found to be, where it is not what is read.
54
+ *
55
+ * @example
56
+ * throw new ShapeError('a feed', 'id', 'missing', 'a number');
57
+ */
58
+ class ShapeError extends Error {
59
+ /**
60
+ * @param what - What the answer is, in the words a person would use.
61
+ * @param field - The field's path; empty for the value itself.
62
+ * @param found - What was found there, as a kind.
63
+ * @param wanted - What is read there.
64
+ */
65
+ constructor(what, field, found, wanted) {
66
+ super(field === '' ? `CUBE answered with ${found} where ${what} (${wanted}) is read` : `CUBE answered ${what} whose ${field} is ${found}, where ${wanted} is read`);
67
+ this.name = 'ShapeError';
68
+ this.what = what;
69
+ this.field = field;
70
+ }
71
+ }
72
+ exports.ShapeError = ShapeError;
73
+ /**
74
+ * The kind a value is, as the checks name kinds.
75
+ *
76
+ * @param value - Any value.
77
+ * @returns `missing`, `null`, `an array`, `an object`, or its `typeof` with its article.
78
+ *
79
+ * @example
80
+ * kind_name([]); // 'an array'
81
+ */
82
+ function kind_name(value) {
83
+ if (value === undefined)
84
+ return 'missing';
85
+ if (value === null)
86
+ return 'null';
87
+ if (Array.isArray(value))
88
+ return 'an array';
89
+ const kind = typeof value;
90
+ return kind === 'object' ? 'an object' : `a ${kind}`;
91
+ }
92
+ /**
93
+ * Whether a value is of a kind.
94
+ *
95
+ * @param value - The value, neither undefined nor null.
96
+ * @param kind - The kind.
97
+ * @returns True when it is.
98
+ *
99
+ * @example
100
+ * kind_matches(3, 'number'); // true
101
+ */
102
+ function kind_matches(value, kind) {
103
+ if (kind === 'array')
104
+ return Array.isArray(value);
105
+ if (kind === 'object')
106
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
107
+ if (kind === 'number')
108
+ return typeof value === 'number' && !Number.isNaN(value);
109
+ return typeof value === kind;
110
+ }
111
+ /**
112
+ * Reads a field's spec.
113
+ *
114
+ * @param name - The field's name.
115
+ * @param spec - What was written for it.
116
+ * @returns The check.
117
+ *
118
+ * @example
119
+ * fieldCheck_read('id', 'number?'); // { name: 'id', kind: 'number', optional: true, nullable: false }
120
+ */
121
+ function fieldCheck_read(name, spec) {
122
+ if (typeof spec === 'string') {
123
+ const nullable = spec.endsWith('|null');
124
+ const rest = nullable ? spec.slice(0, -'|null'.length) : spec;
125
+ const optional = rest.endsWith('?');
126
+ return { name, kind: (optional ? rest.slice(0, -1) : rest), optional, nullable };
127
+ }
128
+ const wrapped = spec;
129
+ if (wrapped.rows !== undefined)
130
+ return { name, kind: 'array', optional: false, nullable: false, rows: wrapped.rows };
131
+ if (wrapped.optional !== undefined)
132
+ return { name, kind: wrapped.optional, optional: true, nullable: false };
133
+ if (wrapped.nullable !== undefined)
134
+ return { name, kind: wrapped.nullable, optional: false, nullable: true };
135
+ return { name, kind: spec, optional: false, nullable: false };
136
+ }
137
+ /**
138
+ * What a field's check reads there, in words.
139
+ *
140
+ * @param check - The field's check.
141
+ * @returns The kind with its article, or the shape's own name.
142
+ *
143
+ * @example
144
+ * wanted_say({ name: 'id', kind: 'number', optional: false, nullable: false }); // 'a number'
145
+ */
146
+ function wanted_say(check) {
147
+ if (typeof check.kind !== 'string')
148
+ return `an object (${check.kind.what})`;
149
+ return check.kind === 'array' || check.kind === 'object' ? `an ${check.kind}` : `a ${check.kind}`;
150
+ }
151
+ /**
152
+ * Holds one field of a record to its check.
153
+ *
154
+ * @param found - What the record has there.
155
+ * @param check - The field's check.
156
+ * @param at - The field's path in the answer.
157
+ * @param outer - What the answer is.
158
+ * @throws {ShapeError} When the field is not what is read.
159
+ *
160
+ * @example
161
+ * field_check(record['id'], check, 'data.id', 'a feed');
162
+ */
163
+ function field_check(found, check, at, outer) {
164
+ if (found === undefined) {
165
+ if (check.optional)
166
+ return;
167
+ throw new ShapeError(outer, at, 'missing', wanted_say(check));
168
+ }
169
+ if (found === null) {
170
+ if (check.nullable)
171
+ return;
172
+ throw new ShapeError(outer, at, 'null', wanted_say(check));
173
+ }
174
+ if (typeof check.kind !== 'string') {
175
+ check.kind.value_check(found, at, outer);
176
+ return;
177
+ }
178
+ if (!kind_matches(found, check.kind))
179
+ throw new ShapeError(outer, at, kind_name(found), wanted_say(check));
180
+ const rows = check.rows;
181
+ if (rows !== undefined) {
182
+ // Every place in the list by its number, a place nothing was put in included: such a hole is a missing row.
183
+ const list = found;
184
+ for (let index = 0; index < list.length; index++)
185
+ rows.value_check(list[index], `${at}[${String(index)}]`, outer);
186
+ }
187
+ }
188
+ /**
189
+ * Makes the shape of an object: a value that is an object (not null, not
190
+ * an array) whose named fields are each what is read.
191
+ *
192
+ * The type is named once, here, and must be an object's (a shape of a
193
+ * number or of text would promise a type its check, which asks for an
194
+ * object, never holds a value to). Each field's spec is held to what the
195
+ * type says of that field, so a shape cannot say `string` of a field the
196
+ * type calls a number, nor allow an absence the type does not.
197
+ *
198
+ * @param what - What the value is, in the words a person would use ("a feed").
199
+ * @returns A function from the fields, each a pair of name and spec, to the shape.
200
+ *
201
+ * @example
202
+ * const FEED: Shape<Feed> = shape_build<Feed>('a feed')(['id', 'number'], ['name', 'string?']);
203
+ */
204
+ function shape_build(what) {
205
+ return (...fields) => {
206
+ const checks = fields.map(([name, spec]) => fieldCheck_read(name, spec));
207
+ return {
208
+ what,
209
+ value_check(value, path = '', outer = what) {
210
+ if (typeof value !== 'object' || value === null || Array.isArray(value))
211
+ throw new ShapeError(outer, path, kind_name(value), path === '' ? 'an object' : `an object (${what})`);
212
+ const record = value;
213
+ for (const check of checks)
214
+ field_check(record[check.name], check, path === '' ? check.name : `${path}.${check.name}`, outer);
215
+ return value;
216
+ },
217
+ };
218
+ };
219
+ }
220
+ /**
221
+ * The shape of a value that is only required to be an object: its fields
222
+ * are the caller's to check before reading.
223
+ *
224
+ * @param what - What the value is.
225
+ * @returns The shape.
226
+ *
227
+ * @example
228
+ * const ROW: Shape<Record<string, unknown>> = shape_object('a permission row');
229
+ */
230
+ function shape_object(what) {
231
+ return shape_build(what)();
232
+ }
233
+ /**
234
+ * The shape of an answer that may be nothing at all: null or undefined is
235
+ * taken as null; anything else is held to the shape.
236
+ *
237
+ * @param shape - The shape of the answer when there is one.
238
+ * @returns A shape of that, or null.
239
+ *
240
+ * @example
241
+ * const FILE_OR_NONE: Shape<UserFile | null> = shape_nullable(FILE);
242
+ */
243
+ function shape_nullable(shape) {
244
+ return {
245
+ what: shape.what,
246
+ value_check(value, path = '', what = shape.what) {
247
+ return value === undefined || value === null ? null : shape.value_check(value, path, what);
248
+ },
249
+ };
250
+ }
251
+ /**
252
+ * Checks a list: a value that is an array, each of whose rows is a `T`.
253
+ *
254
+ * @param value - What CUBE answered where a list is read.
255
+ * @param shape - The shape of a row.
256
+ * @param field - What holds the list (`data`, `items`), for the words.
257
+ * @returns The rows.
258
+ * @throws {ShapeError} When the value is not an array, or a row is not what is read; the row's place is in the field's path.
259
+ *
260
+ * @example
261
+ * const feeds: Feed[] = rows_check(page.data, FEED, 'data');
262
+ */
263
+ function rows_check(value, shape, field) {
264
+ if (!Array.isArray(value))
265
+ throw new ShapeError(`a list of ${shape.what}`, field, kind_name(value), 'an array');
266
+ // Every place in the list by its number: a list with a hole in it has a missing row there, and a walk that
267
+ // skipped holes would hand back a list typed as rows with nothing in that place.
268
+ const list = value;
269
+ const rows = [];
270
+ for (let at = 0; at < list.length; at++)
271
+ rows.push(shape.value_check(list[at], `${field}[${String(at)}]`, `a list of ${shape.what}`));
272
+ return rows;
273
+ }
274
+ //# sourceMappingURL=shape.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shape.js","sourceRoot":"","sources":["../../src/chrisapi/shape.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;;;AAiQH,kCAaC;AAYD,oCAEC;AAYD,wCAOC;AAcD,gCAQC;AA7TD;;;;;GAKG;AACH,MAAa,UAAW,SAAQ,KAAK;IAMnC;;;;;OAKG;IACH,YAAY,IAAY,EAAE,KAAa,EAAE,KAAa,EAAE,MAAc;QACpE,KAAK,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,sBAAsB,KAAK,UAAU,IAAI,KAAK,MAAM,WAAW,CAAC,CAAC,CAAC,iBAAiB,IAAI,UAAU,KAAK,OAAO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.log("\n");
37
37
  console.log("For this set of configuration values read during initialization,");
38
- console.log("the authorization token is: ", await chrisConnection_1.chrisConnection.authToken_get());
38
+ // Whether a token is held is said; the token is a credential and is not printed.
39
+ console.log("an authorization token is", (await chrisConnection_1.chrisConnection.authToken_get()) ? "held" : "not held");
39
40
  console.log("the chris URL is ", await chrisConnection_1.chrisConnection.chrisURL_get());
40
41
  console.log(config_1.connectionConfig);
41
42
  }
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;AACA;;;;GAIG;;;;;AAEH,oDAA4B;AAC5B,2BAAkC;AAClC,+BAA4B;AAG5B,+DAAkF;AAClF,4CAAmD;AACnD,gDAAsD;AAOtD,oBAAoB;AACpB,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAC5B,IAAA,iBAAY,EAAC,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,EAAE,cAAc,CAAC,EAAE,OAAO,CAAC,CAC7D,CAAC;AACF,MAAM,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC;AAEpC;;;GAGG;AACH,KAAK,UAAU,IAAI;IACjB,MAAM,mBAAmB,GAAwB,IAAI,gCAAmB,EAAE,CAAC;IAC3E,MAAM,IAAA,sCAAoB,EAAC,mBAAmB,CAAC,CAAC;IAEhD,OAAO,CAAC,GAAG,CAAC,gBAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;IACtC,OAAO,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;IAChD,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IAChD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAClB,OAAO,CAAC,GAAG,CACT,mEAAmE,CACpE,CAAC;IACF,OAAO,CAAC,GAAG,CACT,yEAAyE,CAC1E,CAAC;IACF,OAAO,CAAC,GAAG,CACT,wEAAwE,CACzE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IAAI,CAAC,CAAC;IAClB,OAAO,CAAC,GAAG,CACT,mEAAmE,CACpE,CAAC;IACF,OAAO,CAAC,GAAG,CACT,yEAAyE,CAC1E,CAAC;IACF,OAAO,CAAC,GAAG,CACT,wEAAwE,CACzE,CAAC;IACF,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;IAClC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAClB,OAAO,CAAC,GAAG,CACT,kEAAkE,CACnE,CAAC;IACF,iFAAiF;IACjF,OAAO,CAAC,GAAG,CAAC,2BAA2B,EAAE,CAAC,MAAM,iCAAe,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;IACxG,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,MAAM,iCAAe,CAAC,YAAY,EAAE,CAAC,CAAC;IACvE,OAAO,CAAC,GAAG,CAAC,yBAAgB,CAAC,CAAC;AAChC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC"}
@@ -7,6 +7,7 @@
7
7
  *
8
8
  * @module
9
9
  */
10
+ import { type Shape } from '../chrisapi/adapter.js';
10
11
  import { ChRISResourceGroup } from '../resources/chrisResourceGroup.js';
11
12
  import { Result } from '../utils/result.js';
12
13
  /**
@@ -25,6 +26,8 @@ export interface ComputeResource {
25
26
  description?: string;
26
27
  [key: string]: unknown;
27
28
  }
29
+ /** A compute resource as CUBE lists it: its name is read as a string wherever a resource is named. */
30
+ export declare const COMPUTE_RESOURCE_SHAPE: Shape<ComputeResource>;
28
31
  /**
29
32
  * Validates that specified compute resources exist in ChRIS CUBE.
30
33
  *
@@ -9,7 +9,7 @@
9
9
  * @module
10
10
  */
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.ChRISComputeResourceGroup = void 0;
12
+ exports.COMPUTE_RESOURCE_SHAPE = exports.ChRISComputeResourceGroup = void 0;
13
13
  exports.computeResources_validate = computeResources_validate;
14
14
  exports.computeResources_getAll = computeResources_getAll;
15
15
  exports.computeResourceNames_parse = computeResourceNames_parse;
@@ -27,6 +27,8 @@ class ChRISComputeResourceGroup extends chrisResourceGroup_js_1.ChRISResourceGro
27
27
  }
28
28
  }
29
29
  exports.ChRISComputeResourceGroup = ChRISComputeResourceGroup;
30
+ /** A compute resource as CUBE lists it: its name is read as a string wherever a resource is named. */
31
+ exports.COMPUTE_RESOURCE_SHAPE = (0, adapter_js_1.shape_build)('a compute resource')(['name', 'string']);
30
32
  /**
31
33
  * Validates that specified compute resources exist in ChRIS CUBE.
32
34
  *
@@ -53,7 +55,7 @@ async function computeResources_validate(resourceNames) {
53
55
  return (0, result_js_1.Err)();
54
56
  }
55
57
  const computeResourceList = await client.getComputeResources();
56
- const resources = (0, adapter_js_1.listData_get)(computeResourceList);
58
+ const resources = (0, adapter_js_1.listData_get)(computeResourceList, exports.COMPUTE_RESOURCE_SHAPE);
57
59
  const availableNames = new Set(resources.map((r) => r.name));
58
60
  // Validate requested resources
59
61
  const invalidResources = resourceNames.filter((name) => !availableNames.has(name));
@@ -84,7 +86,7 @@ async function computeResources_getAll() {
84
86
  return (0, result_js_1.Err)();
85
87
  }
86
88
  const computeResourceList = await client.getComputeResources();
87
- const resources = (0, adapter_js_1.listData_get)(computeResourceList);
89
+ const resources = (0, adapter_js_1.listData_get)(computeResourceList, exports.COMPUTE_RESOURCE_SHAPE);
88
90
  return (0, result_js_1.Ok)(resources);
89
91
  }
90
92
  catch (error) {
@@ -1 +1 @@
1
- {"version":3,"file":"computeResources.js","sourceRoot":"","sources":["../../src/compute/computeResources.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AA8CH,8DAqCC;AAOD,0DAiBC;AAcD,gEAKC;AA5HD,sEAAgE;AAChE,uDAAgF;AAChF,8EAAwE;AACxE,0DAAoD;AACpD,kDAAqD;AAErD;;GAEG;AACH,MAAa,yBAA0B,SAAQ,0CAAkB;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ACpF,MAAM,SAAS,GAAsB,IAAA,yBAAY,EAAC,mBAAmB,EAAE,8BAAsB,CAAC,CAAC;QAE/F,OAAO,IAAA,cAAE,EAAC,SAAS,CAAC,CAAC;IACvB,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACxB,MAAM,YAAY,GAAW,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACpF,0BAAU,CAAC,UAAU,CAAC,OAAO,EAAE,sCAAsC,YAAY,EAAE,CAAC,CAAC;QACrF,OAAO,IAAA,eAAG,GAAE,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,0BAA0B,CAAC,YAA+B;IACxE,IAAI,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;QAChC,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;AACpE,CAAC"}
@@ -33,6 +33,18 @@ export interface SessionConfigOptions {
33
33
  pacsserverFilename?: string;
34
34
  storageProvider?: IStorageProvider;
35
35
  }
36
+ /**
37
+ * A login the saved context names: a user on a CUBE.
38
+ *
39
+ * @example
40
+ * const saved: SavedLogin = { user: 'chris', url: 'https://cube.example/api/v1/' };
41
+ */
42
+ export interface SavedLogin {
43
+ /** The CUBE user name. */
44
+ readonly user: string;
45
+ /** The CUBE address. */
46
+ readonly url: string;
47
+ }
36
48
  /**
37
49
  * Manages configuration for connecting to a ChRIS instance.
38
50
  * Handles storage of user credentials, URLs, and context directories.
@@ -52,6 +64,8 @@ export declare class ConnectionConfig {
52
64
  tokenFilepath: string;
53
65
  readonly currentDirectory: string;
54
66
  debug: boolean;
67
+ /** The user and CUBE the saved context named when the configuration was first read, or null when it named none. */
68
+ loginSaved: SavedLogin | null;
55
69
  private constructor();
56
70
  /**
57
71
  * Get the singleton instance of ConnectionConfig.
@@ -42,7 +42,7 @@ exports.sessionConfig = exports.connectionConfig = exports.SessionConfig = expor
42
42
  exports.config_init = config_init;
43
43
  const errorStack_js_1 = require("../error/errorStack.js");
44
44
  const path = __importStar(require("path"));
45
- const os = __importStar(require("os"));
45
+ const fond_1 = require("@fnndsc/fond");
46
46
  const name = "@fnndsc/cumin";
47
47
  /**
48
48
  * Manages configuration for connecting to a ChRIS instance.
@@ -54,9 +54,10 @@ class ConnectionConfig {
54
54
  }
55
55
  constructor(options = {}, storageProvider) {
56
56
  this.debug = false;
57
+ /** The user and CUBE the saved context named when the configuration was first read, or null when it named none. */
58
+ this.loginSaved = null;
57
59
  this.storageProvider = storageProvider;
58
- const configBase = process.env.XDG_CONFIG_HOME || path.join(os.homedir(), ".config");
59
- this.configDir = path.join(configBase, name);
60
+ this.configDir = path.join((0, fond_1.xdgDir_resolve)("config"), name);
60
61
  this.userFile = options.userFile || "lastUser.txt";
61
62
  this.userFilepath =
62
63
  options.userFilepath || path.join(this.configDir, this.userFile);
@@ -89,6 +90,7 @@ class ConnectionConfig {
89
90
  */
90
91
  async init() {
91
92
  await this.dir_ensureExists(this.configDir);
93
+ this.loginSaved = null;
92
94
  const lastUser = await this.lastUser_load();
93
95
  if (!lastUser) {
94
96
  return;
@@ -101,6 +103,7 @@ class ConnectionConfig {
101
103
  }
102
104
  this.userChRISContextDir = path.join(this.userContextDir, this.uri_convertToDir(lastURL));
103
105
  this.tokenFilepath = path.join(this.userChRISContextDir, this.tokenFile);
106
+ this.loginSaved = { user: lastUser, url: lastURL };
104
107
  }
105
108
  /**
106
109
  * Ensure a directory exists in storage.