@theaiplatform/miniapp-sdk 0.3.2 → 0.4.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.
- package/README.md +126 -0
- package/dist/bin/tap-miniapp-test.d.ts +1 -0
- package/dist/bin/tap-miniapp-test.js +1293 -0
- package/dist/index.d.ts +50 -0
- package/dist/internal/json-schema.d.ts +10 -0
- package/dist/internal/json-schema.js +53 -0
- package/dist/rspack/index.d.ts +72 -6
- package/dist/rspack/index.js +177 -31
- package/dist/sdk.d.ts +50 -0
- package/dist/surface.d.ts +14 -0
- package/dist/testing/rstest-config.d.ts +38 -0
- package/dist/testing/rstest-config.js +59 -0
- package/dist/testing/rstest.d.ts +514 -41
- package/dist/testing/rstest.js +1734 -167
- package/dist/testing/tap.test.schema.json +361 -0
- package/dist/ui/styles.css +504 -6
- package/dist/ui/wasm.js +9231 -510
- package/dist/ui/wasm.js.LICENSE.txt +12 -0
- package/dist/ui.d.ts +14 -4
- package/dist/ui.js +9493 -540
- package/dist/ui.js.LICENSE.txt +12 -0
- package/dist/vscode-webview.d.ts +147 -0
- package/dist/vscode-webview.js +594 -0
- package/dist/web.d.ts +50 -0
- package/package.json +31 -13
package/dist/index.d.ts
CHANGED
|
@@ -124,6 +124,29 @@ export declare type MiniAppAuthApi = {
|
|
|
124
124
|
getUserProfile(): MiniAppMaybePromise<MiniAppUserProfile | null>;
|
|
125
125
|
};
|
|
126
126
|
|
|
127
|
+
/**
|
|
128
|
+
* Read-only authorization introspection for custom surface behavior.
|
|
129
|
+
*
|
|
130
|
+
* The host rejects action IDs that are not declared by the exact mounted
|
|
131
|
+
* surface. A declared action resolves to the current dynamic allow/deny
|
|
132
|
+
* decision without executing the action.
|
|
133
|
+
*/
|
|
134
|
+
export declare type MiniAppAuthorizationApi = {
|
|
135
|
+
check(options: MiniAppAuthorizationCheckOptions): Promise<MiniAppAuthorizationCheckResult>;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
/** Canonical autonomy requested for one descriptor-declared package action. */
|
|
139
|
+
export declare type MiniAppAuthorizationAutonomy = 'listen' | 'plan' | 'do';
|
|
140
|
+
|
|
141
|
+
export declare type MiniAppAuthorizationCheckOptions = {
|
|
142
|
+
actionId: string;
|
|
143
|
+
autonomy: MiniAppAuthorizationAutonomy;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
export declare type MiniAppAuthorizationCheckResult = {
|
|
147
|
+
allowed: boolean;
|
|
148
|
+
};
|
|
149
|
+
|
|
127
150
|
/** Closed discovery taxonomy accepted by `presentation.categories`. */
|
|
128
151
|
export declare type MiniAppCategory = 'productivity' | 'developer-tools' | 'creativity' | 'communication' | 'data-and-analytics' | 'business' | 'education' | 'media-and-entertainment' | 'utilities' | 'other';
|
|
129
152
|
|
|
@@ -346,8 +369,10 @@ export declare type MiniAppPlatformApi = {
|
|
|
346
369
|
navigation: {
|
|
347
370
|
open(options: OpenNavigationOptions): void | Promise<void>;
|
|
348
371
|
};
|
|
372
|
+
authorization: MiniAppAuthorizationApi;
|
|
349
373
|
chat: MiniAppChatApi;
|
|
350
374
|
storage: MiniAppStorageApi;
|
|
375
|
+
session: MiniAppSessionApi;
|
|
351
376
|
presence: MiniAppPresenceApi;
|
|
352
377
|
/** Desktop host capability; feature-detect before use on portable targets. */
|
|
353
378
|
http?: MiniAppHttpApi;
|
|
@@ -507,6 +532,31 @@ export declare type MiniAppReceiptTextAlignment = 'left' | 'center' | 'right';
|
|
|
507
532
|
|
|
508
533
|
export declare type MiniAppReceiptTextWeight = 'normal' | 'bold';
|
|
509
534
|
|
|
535
|
+
/**
|
|
536
|
+
* Secure session storage backed by the operating system credential store.
|
|
537
|
+
*
|
|
538
|
+
* The host derives the signed-in TAP account, active workspace, installation,
|
|
539
|
+
* and package from the authenticated frame. Channel, surface, document, and
|
|
540
|
+
* release are deliberately excluded, so every surface of one installed
|
|
541
|
+
* miniapp shares the same session only within a workspace and package updates
|
|
542
|
+
* retain it. Unlike host-managed HTTP credentials, values returned here enter
|
|
543
|
+
* miniapp JavaScript.
|
|
544
|
+
*/
|
|
545
|
+
export declare type MiniAppSessionApi = {
|
|
546
|
+
get(): MiniAppMaybePromise<MiniAppSessionEntry>;
|
|
547
|
+
set(value: MiniAppSessionValue): MiniAppMaybePromise<void>;
|
|
548
|
+
clear(): MiniAppMaybePromise<void>;
|
|
549
|
+
};
|
|
550
|
+
|
|
551
|
+
export declare type MiniAppSessionEntry = {
|
|
552
|
+
/** Null means that no session value currently exists for this installation. */
|
|
553
|
+
value: MiniAppSessionValue | null;
|
|
554
|
+
};
|
|
555
|
+
|
|
556
|
+
export declare type MiniAppSessionValue = {
|
|
557
|
+
[key: string]: MiniAppJsonValue;
|
|
558
|
+
};
|
|
559
|
+
|
|
510
560
|
export declare type MiniAppSpecialistApi = {
|
|
511
561
|
joinToChannel(channelId: string, specialistId: string): MiniAppMaybePromise<string>;
|
|
512
562
|
listWorkspace(workspaceId: string): MiniAppMaybePromise<MiniAppSpecialistSummary[]>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Format } from 'ajv';
|
|
2
|
+
|
|
3
|
+
/** Register the canonical JSON Schema formats shared by TAP package tooling. */
|
|
4
|
+
export declare function registerTapManifestAjvFormats<Registry extends TapJsonSchemaFormatRegistry>(ajv: Registry): Registry;
|
|
5
|
+
|
|
6
|
+
export declare interface TapJsonSchemaFormatRegistry {
|
|
7
|
+
addFormat(name: string, format: Format): unknown;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { }
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
function isUrl(value) {
|
|
2
|
+
try {
|
|
3
|
+
new URL(value);
|
|
4
|
+
return true;
|
|
5
|
+
} catch {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
function isDateTime(value) {
|
|
10
|
+
const match = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:Z|([+-])(\d{2}):(\d{2}))$/u.exec(value);
|
|
11
|
+
if (!match) return false;
|
|
12
|
+
const year = Number(match[1]);
|
|
13
|
+
const month = Number(match[2]);
|
|
14
|
+
const day = Number(match[3]);
|
|
15
|
+
const hour = Number(match[4]);
|
|
16
|
+
const minute = Number(match[5]);
|
|
17
|
+
const second = Number(match[6]);
|
|
18
|
+
const offsetHour = void 0 === match[8] ? 0 : Number(match[8]);
|
|
19
|
+
const offsetMinute = void 0 === match[9] ? 0 : Number(match[9]);
|
|
20
|
+
if (month < 1 || month > 12 || hour > 23 || minute > 59 || second > 59 || offsetHour > 23 || offsetMinute > 59) return false;
|
|
21
|
+
const calendar = new Date(0);
|
|
22
|
+
calendar.setUTCHours(hour, minute, second, 0);
|
|
23
|
+
calendar.setUTCFullYear(year, month - 1, day);
|
|
24
|
+
return calendar.getUTCFullYear() === year && calendar.getUTCMonth() === month - 1 && calendar.getUTCDate() === day;
|
|
25
|
+
}
|
|
26
|
+
function registerTapManifestAjvFormats(ajv) {
|
|
27
|
+
ajv.addFormat('uri', {
|
|
28
|
+
type: 'string',
|
|
29
|
+
validate: isUrl
|
|
30
|
+
});
|
|
31
|
+
ajv.addFormat('uint8', {
|
|
32
|
+
type: 'number',
|
|
33
|
+
validate: (value)=>Number.isInteger(value) && value >= 0 && value <= 255
|
|
34
|
+
});
|
|
35
|
+
ajv.addFormat('uint16', {
|
|
36
|
+
type: 'number',
|
|
37
|
+
validate: (value)=>Number.isInteger(value) && value >= 0 && value <= 65535
|
|
38
|
+
});
|
|
39
|
+
ajv.addFormat('uint32', {
|
|
40
|
+
type: 'number',
|
|
41
|
+
validate: (value)=>Number.isInteger(value) && value >= 0 && value <= 4294967295
|
|
42
|
+
});
|
|
43
|
+
ajv.addFormat('uint64', {
|
|
44
|
+
type: 'number',
|
|
45
|
+
validate: (value)=>Number.isSafeInteger(value) && value >= 0
|
|
46
|
+
});
|
|
47
|
+
ajv.addFormat('date-time', {
|
|
48
|
+
type: 'string',
|
|
49
|
+
validate: isDateTime
|
|
50
|
+
});
|
|
51
|
+
return ajv;
|
|
52
|
+
}
|
|
53
|
+
export { registerTapManifestAjvFormats };
|
package/dist/rspack/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { Format } from 'ajv';
|
|
2
|
-
import type { LibConfig } from '@rslib/core';
|
|
3
2
|
import { ModuleFederationOptions } from '@module-federation/rsbuild-plugin';
|
|
4
3
|
import { RsbuildPlugin } from '@rsbuild/core';
|
|
5
4
|
|
|
@@ -30,15 +29,42 @@ declare type Config = {
|
|
|
30
29
|
|
|
31
30
|
export declare const pluginTap: (options?: Config) => RsbuildPlugin;
|
|
32
31
|
|
|
33
|
-
/**
|
|
34
|
-
export declare
|
|
32
|
+
/** Register the canonical JSON Schema formats shared by TAP package tooling. */
|
|
33
|
+
export declare function registerTapManifestAjvFormats<Registry extends TapJsonSchemaFormatRegistry>(ajv: Registry): Registry;
|
|
35
34
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
declare interface TapManifestAjvFormatRegistry {
|
|
35
|
+
declare interface TapJsonSchemaFormatRegistry {
|
|
39
36
|
addFormat(name: string, format: Format): unknown;
|
|
40
37
|
}
|
|
41
38
|
|
|
39
|
+
export declare const tapLib: (options?: Config) => TapLibConfig;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Patch-stable Rslib configuration returned by {@link tapLib}.
|
|
43
|
+
*
|
|
44
|
+
* Rslib and Rspack config types contain dependency-private symbols. Publishing
|
|
45
|
+
* those concrete types makes a linked SDK incompatible with a consumer using a
|
|
46
|
+
* different compatible patch release. Keep the extension sections mutable and
|
|
47
|
+
* structurally open while retaining the stable scalar contract owned by TAP.
|
|
48
|
+
*/
|
|
49
|
+
export declare type TapLibConfig = {
|
|
50
|
+
format: 'mf' | 'esm';
|
|
51
|
+
bundle: true;
|
|
52
|
+
autoExternal: false;
|
|
53
|
+
dts: false;
|
|
54
|
+
source?: Record<string, any>;
|
|
55
|
+
output: Record<string, any>;
|
|
56
|
+
tools: {
|
|
57
|
+
rspack?: TapRspackTool;
|
|
58
|
+
[key: string]: any;
|
|
59
|
+
};
|
|
60
|
+
plugins: Array<{
|
|
61
|
+
name: string;
|
|
62
|
+
apply?: any;
|
|
63
|
+
setup: (api: any) => void | Promise<void>;
|
|
64
|
+
[key: string]: any;
|
|
65
|
+
}>;
|
|
66
|
+
};
|
|
67
|
+
|
|
42
68
|
/** Emitted-package scan used to reject machine-local build artifacts. */
|
|
43
69
|
export declare type TapPackageArtifactPortabilityOptions = {
|
|
44
70
|
output: string;
|
|
@@ -58,4 +84,44 @@ export declare type TapPackageAssemblyOptions = {
|
|
|
58
84
|
|
|
59
85
|
export declare type TapPackageTarget = NonNullable<Config['packageTarget']>;
|
|
60
86
|
|
|
87
|
+
export declare type TapRspackConfig = {
|
|
88
|
+
plugins?: any[];
|
|
89
|
+
module?: {
|
|
90
|
+
rules?: any[];
|
|
91
|
+
[key: string]: any;
|
|
92
|
+
};
|
|
93
|
+
resolve?: {
|
|
94
|
+
alias?: false | Record<string, string | false | Array<string | false>>;
|
|
95
|
+
[key: string]: any;
|
|
96
|
+
};
|
|
97
|
+
output?: Record<string, any>;
|
|
98
|
+
[key: string]: any;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export declare type TapRspackConfigMutator = (config: TapRspackNormalizedConfig, context: any) => void | TapRspackConfig | Promise<void | TapRspackConfig>;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Patch-stable subset of the normalized Rspack configuration supplied to
|
|
105
|
+
* `tools.rspack` callbacks.
|
|
106
|
+
*
|
|
107
|
+
* The real Rspack declarations contain dependency-private symbols, so this
|
|
108
|
+
* deliberately keeps extension values open while preserving contextual types
|
|
109
|
+
* for the configuration seams miniapps commonly customize.
|
|
110
|
+
*/
|
|
111
|
+
export declare type TapRspackNormalizedConfig = {
|
|
112
|
+
plugins: any[];
|
|
113
|
+
module: {
|
|
114
|
+
rules?: any[];
|
|
115
|
+
[key: string]: any;
|
|
116
|
+
};
|
|
117
|
+
resolve: {
|
|
118
|
+
alias?: false | Record<string, string | false | Array<string | false>>;
|
|
119
|
+
[key: string]: any;
|
|
120
|
+
};
|
|
121
|
+
output: Record<string, any>;
|
|
122
|
+
[key: string]: any;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export declare type TapRspackTool = TapRspackConfig | TapRspackConfigMutator | Array<TapRspackConfig | TapRspackConfigMutator>;
|
|
126
|
+
|
|
61
127
|
export { }
|