needle-cloud 1.2.0 → 1.2.1-experimental.1e6da59

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.
@@ -3,6 +3,12 @@ export namespace Auth {
3
3
  const baseUrl: string;
4
4
  const redirectUri: string;
5
5
  const postSignOutRedirectUri: string;
6
+ /**
7
+ * Register a callback to be called when the authentication state changes
8
+ * @param {Function} callback - The callback to register
9
+ * @returns {Function} - A function to unregister the callback
10
+ */
11
+ function onChanged(callback: Function): Function;
6
12
  /**
7
13
  * Returns a promise that resolves when Auth is initialized
8
14
  * @returns {Promise<boolean>}
@@ -11,10 +17,10 @@ export namespace Auth {
11
17
  /**
12
18
  * Initialize the Auth system
13
19
  * @internal
14
- * @param {InitOpts} [opts] - Initialization options
20
+ * @param {AuthInitOpts} [opts] - Initialization options
15
21
  * @returns {Promise<boolean>}
16
22
  */
17
- function init(opts?: InitOpts): Promise<boolean>;
23
+ function init(opts?: AuthInitOpts): Promise<boolean>;
18
24
  /**
19
25
  * Check if the user is currently authenticated
20
26
  * @returns {boolean}
@@ -61,11 +67,13 @@ export namespace Auth {
61
67
  function signOut(): Promise<void>;
62
68
  }
63
69
  export type UserInfoResponse = import("@logto/browser").UserInfoResponse;
64
- export type ResourceUrl = "https://cloud.needle.tools/api";
65
- export type InitOpts = {
66
- resource?: ResourceUrl;
70
+ export type ResourceUrl = "https://cloud.needle.tools/api" | ({} & string);
71
+ export type AuthInitOpts = {
72
+ api_endpoint?: string;
67
73
  appId?: string;
68
74
  debug?: boolean;
69
75
  };
70
- declare let appId: string;
76
+ import { api_endpoint } from "../constants.js";
77
+ /** @type {string | undefined} */
78
+ declare let appId: string | undefined;
71
79
  export {};
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Start the checkout process
3
+ * @param {{ price_id:string }} args
4
+ */
5
+ export function startCheckoutSession(args: {
6
+ price_id: string;
7
+ }): Promise<{
8
+ ok: boolean;
9
+ status: number;
10
+ }>;
@@ -27,6 +27,14 @@ export function getDeployments(opts: {
27
27
  offset?: number;
28
28
  limit?: number;
29
29
  }): Promise<Array<Deployment>>;
30
+ /**
31
+ * Get licenses for a specific user. A product type is required
32
+ * @param {{product:string | string[]}} opts
33
+ * @returns {Promise<null | import("../../../../needle-share/types/stripe.js").License[]>}
34
+ */
35
+ export function getUserLicenses(opts: {
36
+ product: string | string[];
37
+ }): Promise<null | import("../../../../needle-share/types/stripe.js").License[]>;
30
38
  /**
31
39
  * Unfortunately this doesnt get properly bundles in the final output so we have to write the types below directly
32
40
  */
@@ -1,2 +1,3 @@
1
1
  export * from "./upload.js";
2
2
  export * from "./get.js";
3
+ export { startCheckoutSession } from "./checkout.js";
@@ -1,2 +1,3 @@
1
1
  export * from "./auth.js";
2
+ export * from "./web-components/index.js";
2
3
  export * from "./functions/index.js";
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Basic web component for login/logout
3
+ */
4
+ export class NeedleLoginButton extends HTMLButtonElement {
5
+ connectedCallback(): void;
6
+ __unsubscribeOnChange: Function;
7
+ disconnectedCallback(): void;
8
+ __update(): void;
9
+ }
@@ -0,0 +1 @@
1
+ export { NeedleLoginButton } from "./LoginButton.js";
@@ -3,6 +3,12 @@ export namespace Auth {
3
3
  const baseUrl: string;
4
4
  const redirectUri: string;
5
5
  const postSignOutRedirectUri: string;
6
+ /**
7
+ * Register a callback to be called when the authentication state changes
8
+ * @param {Function} callback - The callback to register
9
+ * @returns {Function} - A function to unregister the callback
10
+ */
11
+ function onChanged(callback: Function): Function;
6
12
  /**
7
13
  * Returns a promise that resolves when Auth is initialized
8
14
  * @returns {Promise<boolean>}
@@ -11,10 +17,10 @@ export namespace Auth {
11
17
  /**
12
18
  * Initialize the Auth system
13
19
  * @internal
14
- * @param {InitOpts} [opts] - Initialization options
20
+ * @param {AuthInitOpts} [opts] - Initialization options
15
21
  * @returns {Promise<boolean>}
16
22
  */
17
- function init(opts?: InitOpts): Promise<boolean>;
23
+ function init(opts?: AuthInitOpts): Promise<boolean>;
18
24
  /**
19
25
  * Check if the user is currently authenticated
20
26
  * @returns {boolean}
@@ -61,11 +67,13 @@ export namespace Auth {
61
67
  function signOut(): Promise<void>;
62
68
  }
63
69
  export type UserInfoResponse = import("@logto/browser").UserInfoResponse;
64
- export type ResourceUrl = "https://cloud.needle.tools/api";
65
- export type InitOpts = {
66
- resource?: ResourceUrl;
70
+ export type ResourceUrl = "https://cloud.needle.tools/api" | ({} & string);
71
+ export type AuthInitOpts = {
72
+ api_endpoint?: string;
67
73
  appId?: string;
68
74
  debug?: boolean;
69
75
  };
70
- declare let appId: string;
76
+ import { api_endpoint } from "../constants.js";
77
+ /** @type {string | undefined} */
78
+ declare let appId: string | undefined;
71
79
  export {};
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Start the checkout process
3
+ * @param {{ price_id:string }} args
4
+ */
5
+ export function startCheckoutSession(args: {
6
+ price_id: string;
7
+ }): Promise<{
8
+ ok: boolean;
9
+ status: number;
10
+ }>;
@@ -27,6 +27,14 @@ export function getDeployments(opts: {
27
27
  offset?: number;
28
28
  limit?: number;
29
29
  }): Promise<Array<Deployment>>;
30
+ /**
31
+ * Get licenses for a specific user. A product type is required
32
+ * @param {{product:string | string[]}} opts
33
+ * @returns {Promise<null | import("../../../../needle-share/types/stripe.js").License[]>}
34
+ */
35
+ export function getUserLicenses(opts: {
36
+ product: string | string[];
37
+ }): Promise<null | import("../../../../needle-share/types/stripe.js").License[]>;
30
38
  /**
31
39
  * Unfortunately this doesnt get properly bundles in the final output so we have to write the types below directly
32
40
  */
@@ -1,2 +1,3 @@
1
1
  export * from "./upload.js";
2
2
  export * from "./get.js";
3
+ export { startCheckoutSession } from "./checkout.js";
@@ -1,2 +1,3 @@
1
1
  export * from "./auth.js";
2
+ export * from "./web-components/index.js";
2
3
  export * from "./functions/index.js";
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Basic web component for login/logout
3
+ */
4
+ export class NeedleLoginButton extends HTMLButtonElement {
5
+ connectedCallback(): void;
6
+ __unsubscribeOnChange: Function;
7
+ disconnectedCallback(): void;
8
+ __update(): void;
9
+ }
@@ -0,0 +1 @@
1
+ export { NeedleLoginButton } from "./LoginButton.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "needle-cloud",
3
- "version": "1.2.0",
3
+ "version": "1.2.1-experimental.1e6da59",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "needle-cloud": "./bin/cli.js"
@@ -46,7 +46,9 @@
46
46
  "dev:node": "microbundle watch -i ./src/cli.js -o dist/cli.js --format esm --target node --no-compress",
47
47
  "dist": "npx --yes rimraf dist && npm run dist:web && npm run dist:node",
48
48
  "dist:web": "microbundle -i ./src/index.js -o dist/index.js --format esm --generateTypes --target web --sourcemap true --compress true --define api_endpoint=https://cloud.needle.tools/api,cloud_base_url=https://cloud.needle.tools",
49
- "dist:node": "microbundle -i ./src/cli.js -o dist/cli.js --format esm --generateTypes --target node --sourcemap false --compress --define api_endpoint=https://cloud.needle.tools/api,cloud_base_url=https://cloud.needle.tools"
49
+ "dist:web-preview": "microbundle -i ./src/index.js -o dist/index.js --format esm --generateTypes --target web --sourcemap true --compress true --define api_endpoint=https://cloud-staging.needle.tools/api,cloud_base_url=https://cloud-staging.needle.tools",
50
+ "dist:node": "microbundle -i ./src/cli.js -o dist/cli.js --format esm --generateTypes --target node --sourcemap false --compress --define api_endpoint=https://cloud.needle.tools/api,cloud_base_url=https://cloud.needle.tools",
51
+ "dist:node-preview": "microbundle -i ./src/cli.js -o dist/cli.js --format esm --generateTypes --target node --sourcemap false --compress --define api_endpoint=https://cloud-staging.needle.tools/api,cloud_base_url=https://cloud-staging.needle.tools"
50
52
  },
51
53
  "files": [
52
54
  "bin/",
@@ -59,4 +61,4 @@
59
61
  "access": "public",
60
62
  "registry": "https://registry.npmjs.org/"
61
63
  }
62
- }
64
+ }