@aptly-as/sdk-app-web 0.1.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 +12 -0
- package/dist/AptlyWeb.d.ts +16 -0
- package/dist/AptlyWeb.js +47 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +39 -0
package/README.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Media } from '@aptly-as/sdk-web';
|
|
2
|
+
import { AptlyAppWebContext } from '@aptly-as/types';
|
|
3
|
+
export declare class AptlyWeb<S extends object> {
|
|
4
|
+
private _apiUrl;
|
|
5
|
+
private _config;
|
|
6
|
+
readonly media: Media;
|
|
7
|
+
constructor(_apiUrl: string, _config: AptlyAppWebContext<S>);
|
|
8
|
+
get theme(): any;
|
|
9
|
+
get organization(): Pick<import("@aptly-as/types").AptlyOrganization, "_id" | "slug" | "name">;
|
|
10
|
+
get project(): string | undefined;
|
|
11
|
+
get unit(): string | undefined;
|
|
12
|
+
get app(): import("@aptly-as/types").AptlyApp;
|
|
13
|
+
get config(): import("@aptly-as/types").AptlyOrganizationAppConfig<S>;
|
|
14
|
+
getProxyUrl(path: string): string;
|
|
15
|
+
static initFromParentMessage<S extends object>(apiUrl: string, fn: (state: AptlyWeb<S>) => void): () => void;
|
|
16
|
+
}
|
package/dist/AptlyWeb.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Media } from '@aptly-as/sdk-web';
|
|
2
|
+
export class AptlyWeb {
|
|
3
|
+
constructor(_apiUrl, _config) {
|
|
4
|
+
this._apiUrl = _apiUrl;
|
|
5
|
+
this._config = _config;
|
|
6
|
+
this.media = new Media(_config.media.cloudinaryKey);
|
|
7
|
+
}
|
|
8
|
+
get theme() {
|
|
9
|
+
return this._config.theme;
|
|
10
|
+
}
|
|
11
|
+
get organization() {
|
|
12
|
+
return this._config.organization;
|
|
13
|
+
}
|
|
14
|
+
get project() {
|
|
15
|
+
return this._config.project;
|
|
16
|
+
}
|
|
17
|
+
get unit() {
|
|
18
|
+
return this._config.unit;
|
|
19
|
+
}
|
|
20
|
+
get app() {
|
|
21
|
+
return this._config.app;
|
|
22
|
+
}
|
|
23
|
+
get config() {
|
|
24
|
+
return this._config.config;
|
|
25
|
+
}
|
|
26
|
+
getProxyUrl(path) {
|
|
27
|
+
return [
|
|
28
|
+
`${this._apiUrl}/api/v1`,
|
|
29
|
+
`organizations/${this._config.organization.slug}`,
|
|
30
|
+
`apps/${this._config.app.slug}`,
|
|
31
|
+
'proxy',
|
|
32
|
+
path
|
|
33
|
+
].join('/');
|
|
34
|
+
}
|
|
35
|
+
static initFromParentMessage(apiUrl, fn) {
|
|
36
|
+
function setData(e) {
|
|
37
|
+
const parsed = JSON.parse(e.data);
|
|
38
|
+
if (parsed.organization) {
|
|
39
|
+
fn(new AptlyWeb(apiUrl, parsed));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
window.addEventListener('message', setData);
|
|
43
|
+
return () => {
|
|
44
|
+
window.removeEventListener('message', setData);
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './AptlyWeb.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './AptlyWeb.js';
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aptly-as/sdk-app-web",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Aptly app SDK library for frontend development",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"author": "Emil Andreas Olsen <emil@webbod.no>",
|
|
11
|
+
"license": "ISC",
|
|
12
|
+
"devDependencies": {
|
|
13
|
+
"@aptly-as/types": "^2.8.2",
|
|
14
|
+
"@vitest/ui": "^2.1.8",
|
|
15
|
+
"husky": "^9.1.7",
|
|
16
|
+
"lint-staged": "^15.2.11",
|
|
17
|
+
"prettier": "^3.4.2",
|
|
18
|
+
"typescript": "^5.7.2",
|
|
19
|
+
"vitest": "^2.1.8"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@aptly-as/sdk-web": "^0.0.4"
|
|
23
|
+
},
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"@aptly-as/types": "*"
|
|
26
|
+
},
|
|
27
|
+
"lint-staged": {
|
|
28
|
+
"**/*": "prettier --write --ignore-unknown"
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"start": "tsc --incremental --watch",
|
|
32
|
+
"build": "tsc",
|
|
33
|
+
"test": "vitest",
|
|
34
|
+
"test:ui": "vitest --ui --api 9527",
|
|
35
|
+
"test:run": "vitest run",
|
|
36
|
+
"prepublish": "npm run build",
|
|
37
|
+
"postversion": "git push && git push --tags"
|
|
38
|
+
}
|
|
39
|
+
}
|