needle-cloud 1.2.1 → 1.3.0-next.972b095

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.
@@ -0,0 +1,6 @@
1
+ export namespace AuthScopes {
2
+ const Basic: UserScope[];
3
+ const Payment: string[];
4
+ const All: string[];
5
+ }
6
+ import { UserScope } from "@logto/browser";
@@ -1,8 +1,15 @@
1
1
  export namespace Auth {
2
- const debug: boolean;
2
+ /** @param {boolean} _debug */
3
+ function setDebug(_debug: boolean): void;
3
4
  const baseUrl: string;
4
5
  const redirectUri: string;
5
6
  const postSignOutRedirectUri: string;
7
+ /**
8
+ * Register a callback to be called when the authentication state changes
9
+ * @param {Function} callback - The callback to register
10
+ * @returns {Function} - A function to unregister the callback
11
+ */
12
+ function onChanged(callback: Function): Function;
6
13
  /**
7
14
  * Returns a promise that resolves when Auth is initialized
8
15
  * @returns {Promise<boolean>}
@@ -11,10 +18,10 @@ export namespace Auth {
11
18
  /**
12
19
  * Initialize the Auth system
13
20
  * @internal
14
- * @param {InitOpts} [opts] - Initialization options
21
+ * @param {AuthInitOpts} [opts] - Initialization options
15
22
  * @returns {Promise<boolean>}
16
23
  */
17
- function init(opts?: InitOpts): Promise<boolean>;
24
+ function init(opts?: AuthInitOpts): Promise<boolean>;
18
25
  /**
19
26
  * Check if the user is currently authenticated
20
27
  * @returns {boolean}
@@ -61,11 +68,12 @@ export namespace Auth {
61
68
  function signOut(): Promise<void>;
62
69
  }
63
70
  export type UserInfoResponse = import("@logto/browser").UserInfoResponse;
64
- export type ResourceUrl = "https://cloud.needle.tools/api";
65
- export type InitOpts = {
66
- resource?: ResourceUrl;
71
+ export type ResourceUrl = "https://cloud.needle.tools/api" | ({} & string);
72
+ export type AuthInitOpts = {
67
73
  appId?: string;
74
+ /**
75
+ * User scopes. If an empty array is passed
76
+ */
77
+ scopes?: string[] | "payment" | "all";
68
78
  debug?: boolean;
69
79
  };
70
- declare let appId: string;
71
- 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,4 @@
1
1
  export * from "./auth.js";
2
+ export * from "./web-components/index.js";
2
3
  export * from "./functions/index.js";
4
+ export { AuthScopes } from "./auth.config.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";
@@ -0,0 +1,6 @@
1
+ export namespace AuthScopes {
2
+ const Basic: UserScope[];
3
+ const Payment: string[];
4
+ const All: string[];
5
+ }
6
+ import { UserScope } from "@logto/browser";
@@ -1,8 +1,15 @@
1
1
  export namespace Auth {
2
- const debug: boolean;
2
+ /** @param {boolean} _debug */
3
+ function setDebug(_debug: boolean): void;
3
4
  const baseUrl: string;
4
5
  const redirectUri: string;
5
6
  const postSignOutRedirectUri: string;
7
+ /**
8
+ * Register a callback to be called when the authentication state changes
9
+ * @param {Function} callback - The callback to register
10
+ * @returns {Function} - A function to unregister the callback
11
+ */
12
+ function onChanged(callback: Function): Function;
6
13
  /**
7
14
  * Returns a promise that resolves when Auth is initialized
8
15
  * @returns {Promise<boolean>}
@@ -11,10 +18,10 @@ export namespace Auth {
11
18
  /**
12
19
  * Initialize the Auth system
13
20
  * @internal
14
- * @param {InitOpts} [opts] - Initialization options
21
+ * @param {AuthInitOpts} [opts] - Initialization options
15
22
  * @returns {Promise<boolean>}
16
23
  */
17
- function init(opts?: InitOpts): Promise<boolean>;
24
+ function init(opts?: AuthInitOpts): Promise<boolean>;
18
25
  /**
19
26
  * Check if the user is currently authenticated
20
27
  * @returns {boolean}
@@ -61,11 +68,12 @@ export namespace Auth {
61
68
  function signOut(): Promise<void>;
62
69
  }
63
70
  export type UserInfoResponse = import("@logto/browser").UserInfoResponse;
64
- export type ResourceUrl = "https://cloud.needle.tools/api";
65
- export type InitOpts = {
66
- resource?: ResourceUrl;
71
+ export type ResourceUrl = "https://cloud.needle.tools/api" | ({} & string);
72
+ export type AuthInitOpts = {
67
73
  appId?: string;
74
+ /**
75
+ * User scopes. If an empty array is passed
76
+ */
77
+ scopes?: string[] | "payment" | "all";
68
78
  debug?: boolean;
69
79
  };
70
- declare let appId: string;
71
- 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,4 @@
1
1
  export * from "./auth.js";
2
+ export * from "./web-components/index.js";
2
3
  export * from "./functions/index.js";
4
+ export { AuthScopes } from "./auth.config.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.1",
3
+ "version": "1.3.0-next.972b095",
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
+ }