@serve.zone/appstore 0.2.3 → 0.3.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/apps/ghost/versions/1.0.0/config.json +1 -1
- package/apps/grafana/versions/1.0.0/config.json +1 -1
- package/appstore.json +1 -6
- package/changelog.md +15 -1
- package/dist_ts_client/classes.appstoreresolver.d.ts +9 -1
- package/dist_ts_client/classes.appstoreresolver.js +43 -2
- package/dist_ts_client/data.generated.d.ts +2 -0
- package/dist_ts_client/data.generated.js +985 -0
- package/dist_ts_client/index.js +1 -1
- package/dist_ts_client/types.d.ts +13 -0
- package/dist_ts_client/types.js +1 -1
- package/package.json +3 -3
- package/readme.md +9 -3
- package/ts_client/classes.appstoreresolver.ts +50 -1
- package/ts_client/data.generated.ts +987 -0
- package/ts_client/readme.md +66 -0
- package/ts_client/types.ts +15 -0
package/dist_ts_client/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export * from './classes.appstoreresolver.js';
|
|
2
2
|
export * from './types.js';
|
|
3
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi90c19jbGllbnQvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYywrQkFBK0IsQ0FBQztBQUM5QyxjQUFjLFlBQVksQ0FBQyJ9
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type * as interfaces from '@serve.zone/interfaces';
|
|
2
2
|
export type TAppStoreFetch = typeof fetch;
|
|
3
|
+
export type TAppStoreSourceMode = 'package' | 'remote';
|
|
3
4
|
export type TAppStoreIndex = interfaces.appstore.IAppStoreIndex;
|
|
4
5
|
export type TAppStoreApp = interfaces.appstore.IAppStoreApp;
|
|
5
6
|
export type TAppStoreAppMeta = interfaces.appstore.IAppStoreAppMeta;
|
|
@@ -9,11 +10,23 @@ export type TAppStoreRepoManifestSource = interfaces.appstore.IAppStoreRepoManif
|
|
|
9
10
|
export type TAppStoreResolvedSource = interfaces.appstore.IAppStoreResolvedSource;
|
|
10
11
|
export type TServezoneAppStoreManifest = interfaces.appstore.IServezoneAppStoreManifest;
|
|
11
12
|
export interface IAppStoreResolverOptions {
|
|
13
|
+
source?: TAppStoreSourceMode;
|
|
12
14
|
baseUrl?: string;
|
|
13
15
|
fetch?: TAppStoreFetch;
|
|
14
16
|
resolveDockerDigests?: boolean;
|
|
15
17
|
now?: () => Date;
|
|
16
18
|
}
|
|
19
|
+
export interface IAppStorePackageData {
|
|
20
|
+
generatedAt: string;
|
|
21
|
+
jsonFiles: Record<string, unknown>;
|
|
22
|
+
textFiles: Record<string, string>;
|
|
23
|
+
}
|
|
24
|
+
export interface IAppStoreSourceInfo {
|
|
25
|
+
source: TAppStoreSourceMode;
|
|
26
|
+
packageName: string;
|
|
27
|
+
packageVersion: string;
|
|
28
|
+
baseUrl?: string;
|
|
29
|
+
}
|
|
17
30
|
export interface IResolvedAppStoreApp {
|
|
18
31
|
appStoreApp: TAppStoreApp;
|
|
19
32
|
appMeta: TAppStoreAppMeta;
|
package/dist_ts_client/types.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export {};
|
|
2
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi90c19jbGllbnQvdHlwZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serve.zone/appstore",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "serve.zone App Store metadata, parser, and resolver client.",
|
|
6
6
|
"type": "module",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"cloudly"
|
|
46
46
|
],
|
|
47
47
|
"scripts": {
|
|
48
|
-
"test": "tstest test/ --verbose --logfile --timeout 60",
|
|
49
|
-
"build": "tsbuild tsfolders",
|
|
48
|
+
"test": "node scripts/generate-data-module.mjs && tstest test/ --verbose --logfile --timeout 60",
|
|
49
|
+
"build": "node scripts/generate-data-module.mjs && tsbuild tsfolders",
|
|
50
50
|
"buildDocs": "tsdoc"
|
|
51
51
|
}
|
|
52
52
|
}
|
package/readme.md
CHANGED
|
@@ -6,6 +6,12 @@ This repository is the curated App Store index consumed by serve.zone runtimes.
|
|
|
6
6
|
|
|
7
7
|
For reporting bugs, issues, or security vulnerabilities, please visit [community.foss.global/](https://community.foss.global/). This is the central community hub for all issue reporting. Developers who sign and comply with our contribution agreement and go through identification can also get a [code.foss.global/](https://code.foss.global/) account to submit Pull Requests directly.
|
|
8
8
|
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
pnpm add @serve.zone/appstore
|
|
13
|
+
```
|
|
14
|
+
|
|
9
15
|
## What Is In This Repo
|
|
10
16
|
|
|
11
17
|
| File or directory | Purpose |
|
|
@@ -127,7 +133,7 @@ const cloudly = await resolver.getAppMeta('cloudly');
|
|
|
127
133
|
const config = await resolver.getAppVersionConfig('cloudly', cloudly.latestVersion);
|
|
128
134
|
```
|
|
129
135
|
|
|
130
|
-
The resolver defaults to
|
|
136
|
+
The resolver defaults to the App Store data bundled in the published `@serve.zone/appstore` package. Tests and explicit remote consumers can inject a custom `fetch` implementation and base URL.
|
|
131
137
|
|
|
132
138
|
Only include keys that are actually needed by a template. For example, `nginx` is currently just:
|
|
133
139
|
|
|
@@ -141,7 +147,7 @@ Only include keys that are actually needed by a template. For example, `nginx` i
|
|
|
141
147
|
## Working With Templates
|
|
142
148
|
|
|
143
149
|
- Keep `appstore.json`, `apps/<app>/app.json`, and each version config in sync when adding or changing an app.
|
|
144
|
-
- Prefer `source.type=repoManifest`
|
|
150
|
+
- Prefer package-published App Store data for runtime consumers. Use `source.type=repoManifest` only when the linked manifest is intentionally reachable from the runtime environment, or pre-resolve it before publishing an App Store package.
|
|
145
151
|
- Prefer explicit environment variable descriptions because Onebox surfaces them to users during installation.
|
|
146
152
|
- Use platform placeholders such as `${MARIADB_HOST}`, `${MARIADB_PORT}`, `${MARIADB_DATABASE}`, `${MARIADB_USER}`, `${MARIADB_PASSWORD}`, `${MONGODB_URI}`, `${S3_BUCKET}`, `${S3_ACCESS_KEY}`, and `${S3_SECRET_KEY}` only when the matching platform service is declared.
|
|
147
153
|
- Keep template images boring and operationally safe unless there is a reason to pin a more specific upstream tag.
|
|
@@ -174,7 +180,7 @@ Use of these trademarks must comply with Task Venture Capital GmbH's Trademark G
|
|
|
174
180
|
|
|
175
181
|
### Company Information
|
|
176
182
|
|
|
177
|
-
Task Venture Capital GmbH
|
|
183
|
+
Task Venture Capital GmbH<br>
|
|
178
184
|
Registered at District Court Bremen HRB 35230 HB, Germany
|
|
179
185
|
|
|
180
186
|
For any legal inquiries or further information, please contact us via email at hello@task.vc.
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type * as interfaces from '@serve.zone/interfaces';
|
|
2
|
+
import packageJson from '../package.json' with { type: 'json' };
|
|
3
|
+
import { appStorePackageData } from './data.generated.js';
|
|
2
4
|
import type {
|
|
3
5
|
IAppStoreResolverOptions,
|
|
6
|
+
IAppStoreSourceInfo,
|
|
4
7
|
IParsedDockerImageReference,
|
|
5
8
|
IResolvedAppStoreApp,
|
|
6
9
|
TAppStoreApp,
|
|
@@ -8,25 +11,44 @@ import type {
|
|
|
8
11
|
TAppStoreIndex,
|
|
9
12
|
TAppStoreRepoManifestSource,
|
|
10
13
|
TAppStoreResolvedSource,
|
|
14
|
+
TAppStoreSourceMode,
|
|
11
15
|
TAppStoreVersionConfig,
|
|
12
16
|
TServezoneAppStoreManifest,
|
|
13
17
|
} from './types.js';
|
|
14
18
|
|
|
19
|
+
export const appStorePackageMetadata = {
|
|
20
|
+
name: packageJson.name,
|
|
21
|
+
version: packageJson.version,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const appStoreDefaultRemoteBaseUrl = 'https://code.foss.global/serve.zone/appstore/raw/branch/main';
|
|
25
|
+
|
|
15
26
|
export class AppStoreResolver {
|
|
16
27
|
public readonly baseUrl: string;
|
|
17
28
|
private readonly fetchRef: typeof fetch;
|
|
29
|
+
private readonly source: TAppStoreSourceMode;
|
|
18
30
|
private readonly resolveDockerDigests: boolean;
|
|
19
31
|
private readonly now: () => Date;
|
|
20
32
|
private appStoreCache: TAppStoreIndex | null = null;
|
|
21
33
|
private sourceAppCache = new Map<string, IResolvedAppStoreApp>();
|
|
22
34
|
|
|
23
35
|
constructor(optionsArg: IAppStoreResolverOptions = {}) {
|
|
24
|
-
this.
|
|
36
|
+
this.source = optionsArg.source || (optionsArg.baseUrl || optionsArg.fetch ? 'remote' : 'package');
|
|
37
|
+
this.baseUrl = optionsArg.baseUrl || appStoreDefaultRemoteBaseUrl;
|
|
25
38
|
this.fetchRef = optionsArg.fetch || fetch;
|
|
26
39
|
this.resolveDockerDigests = optionsArg.resolveDockerDigests ?? true;
|
|
27
40
|
this.now = optionsArg.now || (() => new Date());
|
|
28
41
|
}
|
|
29
42
|
|
|
43
|
+
public getSourceInfo(): IAppStoreSourceInfo {
|
|
44
|
+
return {
|
|
45
|
+
source: this.source,
|
|
46
|
+
packageName: appStorePackageMetadata.name,
|
|
47
|
+
packageVersion: appStorePackageMetadata.version,
|
|
48
|
+
...(this.source === 'remote' ? { baseUrl: this.baseUrl } : {}),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
30
52
|
public async getAppStoreIndex(): Promise<TAppStoreIndex> {
|
|
31
53
|
if (this.appStoreCache) {
|
|
32
54
|
return this.appStoreCache;
|
|
@@ -400,6 +422,14 @@ export class AppStoreResolver {
|
|
|
400
422
|
}
|
|
401
423
|
|
|
402
424
|
private async fetchJson(pathArg: string): Promise<unknown> {
|
|
425
|
+
if (this.source === 'package') {
|
|
426
|
+
const value = appStorePackageData.jsonFiles[pathArg];
|
|
427
|
+
if (value === undefined) {
|
|
428
|
+
throw new Error(`Packaged App Store file not found: ${pathArg}`);
|
|
429
|
+
}
|
|
430
|
+
return structuredClone(value);
|
|
431
|
+
}
|
|
432
|
+
|
|
403
433
|
const url = `${this.baseUrl}/${pathArg}`;
|
|
404
434
|
const response = await this.fetchRef(url);
|
|
405
435
|
if (!response.ok) {
|
|
@@ -408,6 +438,25 @@ export class AppStoreResolver {
|
|
|
408
438
|
return response.json();
|
|
409
439
|
}
|
|
410
440
|
|
|
441
|
+
public async fetchText(pathArg: string): Promise<string> {
|
|
442
|
+
if (this.source === 'package') {
|
|
443
|
+
if (pathArg in appStorePackageData.textFiles) {
|
|
444
|
+
return appStorePackageData.textFiles[pathArg];
|
|
445
|
+
}
|
|
446
|
+
if (pathArg in appStorePackageData.jsonFiles) {
|
|
447
|
+
return JSON.stringify(appStorePackageData.jsonFiles[pathArg]);
|
|
448
|
+
}
|
|
449
|
+
throw new Error(`Packaged App Store file not found: ${pathArg}`);
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
const url = `${this.baseUrl}/${pathArg}`;
|
|
453
|
+
const response = await this.fetchRef(url);
|
|
454
|
+
if (!response.ok) {
|
|
455
|
+
throw new Error(`HTTP ${response.status} for ${url}`);
|
|
456
|
+
}
|
|
457
|
+
return response.text();
|
|
458
|
+
}
|
|
459
|
+
|
|
411
460
|
private async fetchTextFromUrl(urlArg: string): Promise<string> {
|
|
412
461
|
const response = await this.fetchRef(urlArg);
|
|
413
462
|
if (!response.ok) {
|