@phis/contracts 0.7.4 → 0.7.5
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/README.md +13 -2
- package/dist/access.d.ts +4 -1
- package/dist/access.js +8 -4
- package/dist/media-storage.d.ts +1 -1
- package/dist/media-storage.js +1 -1
- package/dist/media.d.ts +0 -5
- package/dist/media.js +0 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -26,6 +26,15 @@ and change at different moments.
|
|
|
26
26
|
@phis/contracts/server-capabilities the capability snapshot phis reports and the UI acts on
|
|
27
27
|
@phis/contracts/site-groups the membership levels of a Site group, as both ends count them
|
|
28
28
|
@phis/contracts/user-state the shapes a Module may keep a person's decisions in, and the key grammar
|
|
29
|
+
@phis/contracts/references the Page reference grammar both sides derive and compare
|
|
30
|
+
@phis/contracts/resource-links the links from a Phi record into an Add-on's own system
|
|
31
|
+
@phis/contracts/support the Support ticket vocabulary
|
|
32
|
+
@phis/contracts/threads the thread vocabulary
|
|
33
|
+
@phis/contracts/conditions the runtime condition descriptors
|
|
34
|
+
@phis/contracts/controls the Control descriptors
|
|
35
|
+
@phis/contracts/forms the Form descriptors and their parsers
|
|
36
|
+
@phis/contracts/layout the layout vocabulary
|
|
37
|
+
@phis/contracts/timeline the timeline entries
|
|
29
38
|
```
|
|
30
39
|
|
|
31
40
|
## Before the v1 release, interface versions stay at 1
|
|
@@ -74,7 +83,8 @@ What it covers:
|
|
|
74
83
|
- **Schema** -- `PhisAddonSchemaDescriptor` and its column, index and constraint descriptors. Tables are
|
|
75
84
|
declared, not migrated by hand; phis applies them.
|
|
76
85
|
- **Service kinds** -- the Core-owned kinds an Add-on may supply an implementation of: Media Storage
|
|
77
|
-
(`PhisMediaStorageAdapter`, upload plans, object I/O)
|
|
86
|
+
(`PhisMediaStorageAdapter`, upload plans, object I/O), Directory, Payments, Translation and Support
|
|
87
|
+
Forwarding. `PHIS_SERVICE_KINDS` names them
|
|
78
88
|
and `PHIS_SERVICE_INTERFACE_DIGESTS` holds the digest of each kind's current interface; Core refuses an
|
|
79
89
|
Add-on built against a different digest at install.
|
|
80
90
|
- **Core capabilities** -- `PHIS_CORE_CAPABILITIES`, the catalogue ids an Add-on may require. Declare
|
|
@@ -182,7 +192,8 @@ URL is built stays with each side, and phis's numeric Space kind never reaches a
|
|
|
182
192
|
## `/http`
|
|
183
193
|
|
|
184
194
|
The request header names phis reads and the site UI writes: `PHIS_TOKEN_HEADER` (`x-phis-token`),
|
|
185
|
-
`PHIS_SITE_KEY_HEADER`, `PHIS_AREA_HEADER`, `PHIS_REQUEST_PATH_HEADER` and
|
|
195
|
+
`PHIS_SITE_KEY_HEADER`, `PHIS_AREA_HEADER`, `PHIS_REQUEST_PATH_HEADER`, `PHIS_REQUEST_SEARCH_HEADER` and
|
|
196
|
+
`PHIS_FORM_RELAY_HEADER`.
|
|
186
197
|
A disagreement here is not a type error but a 403 or 400 at runtime.
|
|
187
198
|
|
|
188
199
|
## `/locale`
|
package/dist/access.d.ts
CHANGED
|
@@ -85,7 +85,6 @@ export declare const PhiUserEmailSource: {
|
|
|
85
85
|
readonly GitHub: 23;
|
|
86
86
|
};
|
|
87
87
|
export type PhiUserEmailSourceValue = (typeof PhiUserEmailSource)[keyof typeof PhiUserEmailSource];
|
|
88
|
-
export declare function isPhiUserEmailSource(value: unknown): value is PhiUserEmailSourceValue;
|
|
89
88
|
/**
|
|
90
89
|
* Which source a login provider's key stands for.
|
|
91
90
|
*
|
|
@@ -168,6 +167,10 @@ export declare function canPhiAccessSubjectReach(subject: PhiAccessSubject, poli
|
|
|
168
167
|
* keeping stable.
|
|
169
168
|
*/
|
|
170
169
|
export declare function isPhiAccessPolicyProviderOwned(policy: PhiViewerAccessPolicy, ownerProviderId?: PhiRoleProviderId | null): boolean;
|
|
170
|
+
/** Whether a value is a provider id: `@scope/name`, with further segments allowed. */
|
|
171
|
+
export declare function isPhiProviderId(value: unknown): value is `@${string}/${string}`;
|
|
172
|
+
/** Whether a value is a Site group key, as `phis.site_groups.key` accepts it. */
|
|
173
|
+
export declare function isPhiSiteGroupKey(value: unknown): value is string;
|
|
171
174
|
/**
|
|
172
175
|
* Reads a stored descriptor back into a policy, or null.
|
|
173
176
|
*
|
package/dist/access.js
CHANGED
|
@@ -84,10 +84,6 @@ export const PhiUserEmailSource = {
|
|
|
84
84
|
Microsoft: 22,
|
|
85
85
|
GitHub: 23,
|
|
86
86
|
};
|
|
87
|
-
export function isPhiUserEmailSource(value) {
|
|
88
|
-
return typeof value === "number"
|
|
89
|
-
&& Object.values(PhiUserEmailSource).includes(value);
|
|
90
|
-
}
|
|
91
87
|
/**
|
|
92
88
|
* Which source a login provider's key stands for.
|
|
93
89
|
*
|
|
@@ -182,6 +178,14 @@ export function isPhiAccessPolicyProviderOwned(policy, ownerProviderId) {
|
|
|
182
178
|
}
|
|
183
179
|
const PROVIDER_ID_PATTERN = /^@[^/]+\/[^/]+(?:\/[^/]+)*$/;
|
|
184
180
|
const GROUP_KEY_PATTERN = /^[a-z0-9][a-z0-9._-]{0,159}$/u;
|
|
181
|
+
/** Whether a value is a provider id: `@scope/name`, with further segments allowed. */
|
|
182
|
+
export function isPhiProviderId(value) {
|
|
183
|
+
return typeof value === "string" && PROVIDER_ID_PATTERN.test(value);
|
|
184
|
+
}
|
|
185
|
+
/** Whether a value is a Site group key, as `phis.site_groups.key` accepts it. */
|
|
186
|
+
export function isPhiSiteGroupKey(value) {
|
|
187
|
+
return typeof value === "string" && GROUP_KEY_PATTERN.test(value);
|
|
188
|
+
}
|
|
185
189
|
/** The same shape an Add-on manifest may declare a role under. */
|
|
186
190
|
const ADDON_ROLE_NAME_PATTERN = /^[a-z][a-z0-9-]{0,63}$/;
|
|
187
191
|
/**
|
package/dist/media-storage.d.ts
CHANGED
|
@@ -294,7 +294,7 @@ export type PhiMediaUploadCompletionInput = {
|
|
|
294
294
|
*/
|
|
295
295
|
export declare const PHIS_MEDIA_CHECKSUM_ALGORITHMS: readonly ["sha256", "sha512", "sha256-composite", "xxhash128", "crc64nvme", "crc32c", "crc32", "md5"];
|
|
296
296
|
export type PhisMediaChecksumAlgorithm = (typeof PHIS_MEDIA_CHECKSUM_ALGORITHMS)[number];
|
|
297
|
-
export { PHIS_MEDIA_UPLOAD_MAX_PART_COUNT, PHIS_MEDIA_UPLOAD_PART_SIZE_BYTES, formatPhiMediaCompositeChecksum,
|
|
297
|
+
export { PHIS_MEDIA_UPLOAD_MAX_PART_COUNT, PHIS_MEDIA_UPLOAD_PART_SIZE_BYTES, formatPhiMediaCompositeChecksum, resolvePhiMediaUploadPartCount, resolvePhiMediaUploadPartSizeBytes, } from "./media.js";
|
|
298
298
|
/**
|
|
299
299
|
* The digests strong enough to answer "is this the same file", rather than only "did it arrive intact".
|
|
300
300
|
*
|
package/dist/media-storage.js
CHANGED
|
@@ -36,7 +36,7 @@ export const PHIS_MEDIA_CHECKSUM_ALGORITHMS = [
|
|
|
36
36
|
* that request is signed. So the rule cannot sit behind the Add-on surface, and it must not be written
|
|
37
37
|
* twice -- two copies of a division are two divisions the day one of them is edited.
|
|
38
38
|
*/
|
|
39
|
-
export { PHIS_MEDIA_UPLOAD_MAX_PART_COUNT, PHIS_MEDIA_UPLOAD_PART_SIZE_BYTES, formatPhiMediaCompositeChecksum,
|
|
39
|
+
export { PHIS_MEDIA_UPLOAD_MAX_PART_COUNT, PHIS_MEDIA_UPLOAD_PART_SIZE_BYTES, formatPhiMediaCompositeChecksum, resolvePhiMediaUploadPartCount, resolvePhiMediaUploadPartSizeBytes, } from "./media.js";
|
|
40
40
|
/**
|
|
41
41
|
* The digests strong enough to answer "is this the same file", rather than only "did it arrive intact".
|
|
42
42
|
*
|
package/dist/media.d.ts
CHANGED
|
@@ -265,8 +265,3 @@ export declare function resolvePhiMediaUploadPartCount(sizeBytes: number): numbe
|
|
|
265
265
|
* SHA-256 that simply failed to match. Naming the division makes a mismatch legible instead of puzzling.
|
|
266
266
|
*/
|
|
267
267
|
export declare function formatPhiMediaCompositeChecksum(digestHex: string, partCount: number, partSizeBytes: number): string;
|
|
268
|
-
export declare function parsePhiMediaCompositeChecksum(value: string): {
|
|
269
|
-
digest: string;
|
|
270
|
-
partCount: number;
|
|
271
|
-
partSizeBytes: number;
|
|
272
|
-
} | null;
|
package/dist/media.js
CHANGED
|
@@ -409,13 +409,3 @@ export function resolvePhiMediaUploadPartCount(sizeBytes) {
|
|
|
409
409
|
export function formatPhiMediaCompositeChecksum(digestHex, partCount, partSizeBytes) {
|
|
410
410
|
return `${digestHex.toLowerCase()}-${partCount}-${partSizeBytes}`;
|
|
411
411
|
}
|
|
412
|
-
export function parsePhiMediaCompositeChecksum(value) {
|
|
413
|
-
const match = /^([0-9a-f]{64})-(\d{1,5})-(\d{1,12})$/u.exec(value.trim().toLowerCase());
|
|
414
|
-
if (!match)
|
|
415
|
-
return null;
|
|
416
|
-
const partCount = Number(match[2]);
|
|
417
|
-
const partSizeBytes = Number(match[3]);
|
|
418
|
-
if (partCount < 1 || partSizeBytes < 1)
|
|
419
|
-
return null;
|
|
420
|
-
return { digest: match[1], partCount, partSizeBytes };
|
|
421
|
-
}
|