@artemis-apps/contracts 0.0.0-stage → 0.1.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/dist/activity.d.ts +150 -0
- package/dist/activity.js +159 -0
- package/dist/api-error.d.ts +8 -0
- package/dist/api-error.js +7 -0
- package/dist/app-protocol.d.ts +290 -0
- package/dist/app-protocol.js +357 -0
- package/dist/app-session-state.d.ts +98 -0
- package/dist/app-session-state.js +38 -0
- package/dist/core-api.d.ts +799 -0
- package/dist/core-api.js +345 -0
- package/dist/entities/account.entity.d.ts +34 -0
- package/dist/entities/account.entity.js +15 -0
- package/dist/entities/avatar.entity.d.ts +31 -0
- package/dist/entities/avatar.entity.js +30 -0
- package/dist/entities/entity-name.d.ts +3 -0
- package/dist/entities/entity-name.js +2 -0
- package/dist/entities.d.ts +350 -0
- package/dist/entities.js +200 -0
- package/dist/entity-shares.d.ts +86 -0
- package/dist/entity-shares.js +29 -0
- package/dist/entity-types.d.ts +153 -0
- package/dist/entity-types.js +248 -0
- package/dist/images.d.ts +6 -0
- package/dist/images.js +10 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +24 -0
- package/dist/marketplace.d.ts +183 -0
- package/dist/marketplace.js +162 -0
- package/dist/oidc.d.ts +25 -0
- package/dist/oidc.js +36 -0
- package/dist/permissions.d.ts +70 -0
- package/dist/permissions.js +101 -0
- package/dist/preferences.d.ts +30 -0
- package/dist/preferences.js +18 -0
- package/dist/return-path.d.ts +7 -0
- package/dist/return-path.js +21 -0
- package/dist/route-path.d.ts +5 -0
- package/dist/route-path.js +10 -0
- package/dist/storage.d.ts +43 -0
- package/dist/storage.js +39 -0
- package/dist/web-url.d.ts +7 -0
- package/dist/web-url.js +7 -0
- package/package.json +45 -3
- package/README.md +0 -3
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Turns a route pattern (`/api/apps/:appId`) into a concrete, encoded path. */
|
|
2
|
+
export function fillPath(pattern, parameters) {
|
|
3
|
+
const values = parameters;
|
|
4
|
+
return pattern.replace(/:([A-Za-z]+)/g, (_match, name) => {
|
|
5
|
+
const value = values[name];
|
|
6
|
+
if (value === undefined)
|
|
7
|
+
throw new Error(`Missing path parameter "${name}".`);
|
|
8
|
+
return encodeURIComponent(value);
|
|
9
|
+
});
|
|
10
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* - `public`: anyone holding its unguessable URL can display it (avatars, images shown across
|
|
4
|
+
* apps). Served sandboxed and `nosniff`: content can show, never run as the core;
|
|
5
|
+
* - `private`: only the owning app's server can read it, and relays it after its own checks.
|
|
6
|
+
*/
|
|
7
|
+
export declare const FILE_VISIBILITIES: readonly ['public', 'private'];
|
|
8
|
+
export declare const FileVisibilitySchema: z.ZodEnum<{
|
|
9
|
+
private: "private";
|
|
10
|
+
public: "public";
|
|
11
|
+
}>;
|
|
12
|
+
export type FileVisibility = z.infer<typeof FileVisibilitySchema>;
|
|
13
|
+
/** Largest file the core storage keeps. */
|
|
14
|
+
export declare const MAX_STORED_FILE_BYTES: number;
|
|
15
|
+
export declare const StoredFileSchema: z.ZodObject<{
|
|
16
|
+
id: z.ZodUUID;
|
|
17
|
+
visibility: z.ZodEnum<{
|
|
18
|
+
private: "private";
|
|
19
|
+
public: "public";
|
|
20
|
+
}>;
|
|
21
|
+
contentType: z.ZodString;
|
|
22
|
+
size: z.ZodNumber;
|
|
23
|
+
createdAt: z.ZodISODateTime;
|
|
24
|
+
publicUrl: z.ZodNullable<z.ZodURL>;
|
|
25
|
+
}, z.core.$strip>;
|
|
26
|
+
export type StoredFile = z.infer<typeof StoredFileSchema>;
|
|
27
|
+
/** Multipart form fields of an upload (besides the `file` part). */
|
|
28
|
+
export declare const FileUploadFieldsSchema: z.ZodObject<{
|
|
29
|
+
visibility: z.ZodEnum<{
|
|
30
|
+
private: "private";
|
|
31
|
+
public: "public";
|
|
32
|
+
}>;
|
|
33
|
+
}, z.core.$strip>;
|
|
34
|
+
export type FileUploadFields = z.input<typeof FileUploadFieldsSchema>;
|
|
35
|
+
/** Route patterns of the core storage. Fill `:params` with `fillPath`. */
|
|
36
|
+
export declare const CORE_STORAGE_PATHS: {
|
|
37
|
+
/** POST multipart (`file` + `FileUploadFields`) → 201 `StoredFile`. App-authenticated. */
|
|
38
|
+
readonly files: '/api/storage/files';
|
|
39
|
+
/** GET → the content (owning app only, any visibility); DELETE → 204. App-authenticated. */
|
|
40
|
+
readonly file: '/api/storage/files/:fileId';
|
|
41
|
+
/** GET → the content of a PUBLIC file, for any origin. Long-lived cache. */
|
|
42
|
+
readonly publicFile: '/files/:fileId';
|
|
43
|
+
};
|
package/dist/storage.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/*
|
|
3
|
+
* Core storage: every file belongs to an app (its OIDC client), never to a person. Apps manage
|
|
4
|
+
* their files server to server, authenticated with their client credentials (HTTP Basic).
|
|
5
|
+
* Who may see a private file is the owning app's business, enforced by its own server.
|
|
6
|
+
* The storage only keeps files: what they are (types, pictures, sizes of images) is the apps'
|
|
7
|
+
* business. It keeps the declared content type to serve them back, inert.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* - `public`: anyone holding its unguessable URL can display it (avatars, images shown across
|
|
11
|
+
* apps). Served sandboxed and `nosniff`: content can show, never run as the core;
|
|
12
|
+
* - `private`: only the owning app's server can read it, and relays it after its own checks.
|
|
13
|
+
*/
|
|
14
|
+
export const FILE_VISIBILITIES = ['public', 'private'];
|
|
15
|
+
export const FileVisibilitySchema = z.enum(FILE_VISIBILITIES);
|
|
16
|
+
/** Largest file the core storage keeps. */
|
|
17
|
+
export const MAX_STORED_FILE_BYTES = 50 * 1024 * 1024;
|
|
18
|
+
export const StoredFileSchema = z.object({
|
|
19
|
+
id: z.uuidv4(),
|
|
20
|
+
visibility: FileVisibilitySchema,
|
|
21
|
+
contentType: z.string(),
|
|
22
|
+
size: z.number().int().nonnegative(),
|
|
23
|
+
createdAt: z.iso.datetime(),
|
|
24
|
+
/** Set for public files only. */
|
|
25
|
+
publicUrl: z.url().nullable(),
|
|
26
|
+
});
|
|
27
|
+
/** Multipart form fields of an upload (besides the `file` part). */
|
|
28
|
+
export const FileUploadFieldsSchema = z.object({
|
|
29
|
+
visibility: FileVisibilitySchema,
|
|
30
|
+
});
|
|
31
|
+
/** Route patterns of the core storage. Fill `:params` with `fillPath`. */
|
|
32
|
+
export const CORE_STORAGE_PATHS = {
|
|
33
|
+
/** POST multipart (`file` + `FileUploadFields`) → 201 `StoredFile`. App-authenticated. */
|
|
34
|
+
files: '/api/storage/files',
|
|
35
|
+
/** GET → the content (owning app only, any visibility); DELETE → 204. App-authenticated. */
|
|
36
|
+
file: '/api/storage/files/:fileId',
|
|
37
|
+
/** GET → the content of a PUBLIC file, for any origin. Long-lived cache. */
|
|
38
|
+
publicFile: '/files/:fileId',
|
|
39
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* An absolute `http:` or `https:` URL: what an app may hand the platform as a link or an icon.
|
|
4
|
+
* Other schemes (`javascript:`, `data:`) would run or show in whichever app renders the link,
|
|
5
|
+
* and apps never trust each other.
|
|
6
|
+
*/
|
|
7
|
+
export declare const WebUrlSchema: z.ZodURL;
|
package/dist/web-url.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* An absolute `http:` or `https:` URL: what an app may hand the platform as a link or an icon.
|
|
4
|
+
* Other schemes (`javascript:`, `data:`) would run or show in whichever app renders the link,
|
|
5
|
+
* and apps never trust each other.
|
|
6
|
+
*/
|
|
7
|
+
export const WebUrlSchema = z.url({ protocol: /^https?$/ });
|
package/package.json
CHANGED
|
@@ -1,6 +1,48 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@artemis-apps/contracts",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"sideEffects": false,
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"default": "./dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"./contacts": {
|
|
12
|
+
"types": "./dist/contacts/index.d.ts",
|
|
13
|
+
"default": "./dist/contacts/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./google": {
|
|
16
|
+
"types": "./dist/google/index.d.ts",
|
|
17
|
+
"default": "./dist/google/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./office": {
|
|
20
|
+
"types": "./dist/office/index.d.ts",
|
|
21
|
+
"default": "./dist/office/index.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"zod": "4.6.7"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"typescript": "7.0.2",
|
|
29
|
+
"vitest": "5.1.2",
|
|
30
|
+
"@artemis-apps/tsconfig": "^0.1.1"
|
|
31
|
+
},
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "git+https://github.com/artemis-apps/sdk.git",
|
|
35
|
+
"directory": "packages/contracts"
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"dist"
|
|
39
|
+
],
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "tsc --project tsconfig.build.json",
|
|
45
|
+
"typecheck": "tsc --project tsconfig.json",
|
|
46
|
+
"test": "vitest run"
|
|
47
|
+
}
|
|
6
48
|
}
|
package/README.md
DELETED