needle-cloud 1.0.0 → 1.1.0-alpha

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,65 @@
1
+ export namespace Auth {
2
+ const baseUrl: string;
3
+ const redirectUri: string;
4
+ const postSignOutRedirectUri: string;
5
+ /**
6
+ * Returns a promise that resolves when Auth is initialized
7
+ * @returns {Promise<boolean>}
8
+ */
9
+ function ready(): Promise<boolean>;
10
+ /**
11
+ * Initialize the Auth system
12
+ * @internal
13
+ * @param {InitOpts} [opts] - Initialization options
14
+ * @returns {Promise<boolean>}
15
+ */
16
+ function init(opts?: InitOpts): Promise<boolean>;
17
+ /**
18
+ * Check if the user is currently authenticated
19
+ * @returns {boolean}
20
+ */
21
+ function isAuthenticated(): boolean;
22
+ /**
23
+ * Check authentication status with the server
24
+ * @returns {Promise<boolean>}
25
+ */
26
+ function checkIsAuthenticated(): Promise<boolean>;
27
+ /**
28
+ * Get the current user information
29
+ * @returns {UserInfoResponse|null}
30
+ */
31
+ function getUserInfo(): import("@logto/browser").UserInfoResponse;
32
+ /**
33
+ * Get the current user ID
34
+ * @returns {string|null}
35
+ */
36
+ function getUserId(): string;
37
+ /**
38
+ * Get the user's name or username
39
+ * @returns {string|null}
40
+ */
41
+ function getName(): string;
42
+ /**
43
+ * Request user information from the server
44
+ * @returns {Promise<UserInfoResponse|null>}
45
+ */
46
+ function requestUserInfo(): Promise<import("@logto/browser").UserInfoResponse>;
47
+ /**
48
+ * Request an access token for the configured resource
49
+ * @returns {Promise<string>}
50
+ */
51
+ function requestAccessToken(): Promise<string>;
52
+ /**
53
+ * Initiate the sign-in process
54
+ */
55
+ function signIn(): void;
56
+ /**
57
+ * Sign out the current user
58
+ */
59
+ function signOut(): void;
60
+ }
61
+ export type UserInfoResponse = import("@logto/browser").UserInfoResponse;
62
+ export type ResourceUrl = "https://cloud.needle.tools/api";
63
+ export type InitOpts = {
64
+ resource?: ResourceUrl;
65
+ };
@@ -0,0 +1,103 @@
1
+ /**
2
+ * import("@needle-tools/cloud-sdk/types").FileLike
3
+ */
4
+ /**
5
+ * @typedef {{ token: string, endpoint?:string }} AuthData
6
+ * @typedef {{ name: string, mimetype: string, buffer:Buffer }} Filelike
7
+ */
8
+ /**
9
+ * @param {Array<Filelike>} files
10
+ * @param {AuthData & {
11
+ * name?:string,
12
+ * abort?:AbortSignal,
13
+ * }} opts
14
+ * @returns {Promise<{error:string} | {job_id:string, view_id:string, url?:string | null, skipped?:boolean}>}
15
+ */
16
+ export function uploadFiles(files: Array<Filelike>, opts: AuthData & {
17
+ name?: string;
18
+ abort?: AbortSignal;
19
+ }): Promise<{
20
+ error: string;
21
+ } | {
22
+ job_id: string;
23
+ view_id: string;
24
+ url?: string | null;
25
+ skipped?: boolean;
26
+ }>;
27
+ /**
28
+ * Unfortunately this doesnt get properly bundles in the final output so we have to write the types below directly
29
+ * @typedef {import("@needle-tools/cloud-sdk/types").JobType} JobType
30
+ * @typedef {import("@needle-tools/cloud-sdk/types").JobStatus} JobStatus
31
+ */
32
+ /**
33
+ * @typedef {{
34
+ * name: string,
35
+ * thumbnail_url?: string,
36
+ * created_at: string,
37
+ * updated_at: string,
38
+ * files: Array<{
39
+ * type: "upload" | "conversion" | "optimization" | "deployment",
40
+ * status: "failed" | "completed" | (string & {}),
41
+ * created_at: string,
42
+ * updated_at: string,
43
+ * name? :string,
44
+ * url:string | null,
45
+ * size: number,
46
+ * }>}} Upload
47
+ */
48
+ /**
49
+ * @param {AuthData & ({ name?: string, view_id?:string } | { page: number, limit: number })} opts
50
+ * @returns {Promise<Array<Upload>>}
51
+ */
52
+ export function getUploads(opts: AuthData & ({
53
+ name?: string;
54
+ view_id?: string;
55
+ } | {
56
+ page: number;
57
+ limit: number;
58
+ })): Promise<Array<Upload>>;
59
+ /**
60
+ * @param {AuthData & { offset?:number, limit?: number }} opts
61
+ * @returns {Promise<Array<Deployment>>}
62
+ * @typedef {{ name: string, url: string }} Deployment
63
+ */
64
+ export function getDeployments(opts: AuthData & {
65
+ offset?: number;
66
+ limit?: number;
67
+ }): Promise<Array<Deployment>>;
68
+ export type AuthData = {
69
+ token: string;
70
+ endpoint?: string;
71
+ };
72
+ export type Filelike = {
73
+ name: string;
74
+ mimetype: string;
75
+ buffer: Buffer;
76
+ };
77
+ /**
78
+ * Unfortunately this doesnt get properly bundles in the final output so we have to write the types below directly
79
+ */
80
+ export type JobType = import("@needle-tools/cloud-sdk/types").JobType;
81
+ /**
82
+ * Unfortunately this doesnt get properly bundles in the final output so we have to write the types below directly
83
+ */
84
+ export type JobStatus = import("@needle-tools/cloud-sdk/types").JobStatus;
85
+ export type Upload = {
86
+ name: string;
87
+ thumbnail_url?: string;
88
+ created_at: string;
89
+ updated_at: string;
90
+ files: Array<{
91
+ type: "upload" | "conversion" | "optimization" | "deployment";
92
+ status: "failed" | "completed" | (string & {});
93
+ created_at: string;
94
+ updated_at: string;
95
+ name?: string;
96
+ url: string | null;
97
+ size: number;
98
+ }>;
99
+ };
100
+ export type Deployment = {
101
+ name: string;
102
+ url: string;
103
+ };
@@ -1,103 +1,2 @@
1
- /**
2
- * import("@needle-tools/cloud-sdk/types").FileLike
3
- */
4
- /**
5
- * @typedef {{ token: string, endpoint?:string }} AuthData
6
- * @typedef {{ name: string, mimetype: string, buffer:Buffer }} Filelike
7
- */
8
- /**
9
- * @param {Array<Filelike>} files
10
- * @param {AuthData & {
11
- * name?:string,
12
- * abort?:AbortSignal,
13
- * }} opts
14
- * @returns {Promise<{error:string} | {job_id:string, view_id:string, url?:string, skipped?:boolean}>}
15
- */
16
- export function uploadFiles(files: Array<Filelike>, opts: AuthData & {
17
- name?: string;
18
- abort?: AbortSignal;
19
- }): Promise<{
20
- error: string;
21
- } | {
22
- job_id: string;
23
- view_id: string;
24
- url?: string;
25
- skipped?: boolean;
26
- }>;
27
- /**
28
- * Unfortunately this doesnt get properly bundles in the final output so we have to write the types below directly
29
- * @typedef {import("@needle-tools/cloud-sdk/types").JobType} JobType
30
- * @typedef {import("@needle-tools/cloud-sdk/types").JobStatus} JobStatus
31
- */
32
- /**
33
- * @typedef {{
34
- * name: string,
35
- * thumbnail_url?: string,
36
- * created_at: string,
37
- * updated_at: string,
38
- * files: Array<{
39
- * type: "upload" | "conversion" | "optimization" | "deployment",
40
- * status: "failed" | "completed" | (string & {}),
41
- * created_at: string,
42
- * updated_at: string,
43
- * name? :string,
44
- * url:string | null,
45
- * size: number,
46
- * }>}} Upload
47
- */
48
- /**
49
- * @param {AuthData & ({ name?: string, view_id?:string } | { page: number, limit: number })} opts
50
- * @returns {Promise<Array<Upload>>}
51
- */
52
- export function getUploads(opts: AuthData & ({
53
- name?: string;
54
- view_id?: string;
55
- } | {
56
- page: number;
57
- limit: number;
58
- })): Promise<Array<Upload>>;
59
- /**
60
- * @param {AuthData & { offset?:number, limit?: number }} opts
61
- * @returns {Promise<Array<Deployment>>}
62
- * @typedef {{ name: string, url: string }} Deployment
63
- */
64
- export function getDeployments(opts: AuthData & {
65
- offset?: number;
66
- limit?: number;
67
- }): Promise<Array<Deployment>>;
68
- export type AuthData = {
69
- token: string;
70
- endpoint?: string;
71
- };
72
- export type Filelike = {
73
- name: string;
74
- mimetype: string;
75
- buffer: Buffer;
76
- };
77
- /**
78
- * Unfortunately this doesnt get properly bundles in the final output so we have to write the types below directly
79
- */
80
- export type JobType = import("@needle-tools/cloud-sdk/types").JobType;
81
- /**
82
- * Unfortunately this doesnt get properly bundles in the final output so we have to write the types below directly
83
- */
84
- export type JobStatus = import("@needle-tools/cloud-sdk/types").JobStatus;
85
- export type Upload = {
86
- name: string;
87
- thumbnail_url?: string;
88
- created_at: string;
89
- updated_at: string;
90
- files: Array<{
91
- type: "upload" | "conversion" | "optimization" | "deployment";
92
- status: "failed" | "completed" | (string & {});
93
- created_at: string;
94
- updated_at: string;
95
- name?: string;
96
- url: string | null;
97
- size: number;
98
- }>;
99
- };
100
- export type Deployment = {
101
- name: string;
102
- url: string;
103
- };
1
+ export * from "./auth.js";
2
+ export * from "./functions.js";
@@ -0,0 +1,65 @@
1
+ export namespace Auth {
2
+ const baseUrl: string;
3
+ const redirectUri: string;
4
+ const postSignOutRedirectUri: string;
5
+ /**
6
+ * Returns a promise that resolves when Auth is initialized
7
+ * @returns {Promise<boolean>}
8
+ */
9
+ function ready(): Promise<boolean>;
10
+ /**
11
+ * Initialize the Auth system
12
+ * @internal
13
+ * @param {InitOpts} [opts] - Initialization options
14
+ * @returns {Promise<boolean>}
15
+ */
16
+ function init(opts?: InitOpts): Promise<boolean>;
17
+ /**
18
+ * Check if the user is currently authenticated
19
+ * @returns {boolean}
20
+ */
21
+ function isAuthenticated(): boolean;
22
+ /**
23
+ * Check authentication status with the server
24
+ * @returns {Promise<boolean>}
25
+ */
26
+ function checkIsAuthenticated(): Promise<boolean>;
27
+ /**
28
+ * Get the current user information
29
+ * @returns {UserInfoResponse|null}
30
+ */
31
+ function getUserInfo(): import("@logto/browser").UserInfoResponse;
32
+ /**
33
+ * Get the current user ID
34
+ * @returns {string|null}
35
+ */
36
+ function getUserId(): string;
37
+ /**
38
+ * Get the user's name or username
39
+ * @returns {string|null}
40
+ */
41
+ function getName(): string;
42
+ /**
43
+ * Request user information from the server
44
+ * @returns {Promise<UserInfoResponse|null>}
45
+ */
46
+ function requestUserInfo(): Promise<import("@logto/browser").UserInfoResponse>;
47
+ /**
48
+ * Request an access token for the configured resource
49
+ * @returns {Promise<string>}
50
+ */
51
+ function requestAccessToken(): Promise<string>;
52
+ /**
53
+ * Initiate the sign-in process
54
+ */
55
+ function signIn(): void;
56
+ /**
57
+ * Sign out the current user
58
+ */
59
+ function signOut(): void;
60
+ }
61
+ export type UserInfoResponse = import("@logto/browser").UserInfoResponse;
62
+ export type ResourceUrl = "https://cloud.needle.tools/api";
63
+ export type InitOpts = {
64
+ resource?: ResourceUrl;
65
+ };
@@ -0,0 +1,103 @@
1
+ /**
2
+ * import("@needle-tools/cloud-sdk/types").FileLike
3
+ */
4
+ /**
5
+ * @typedef {{ token: string, endpoint?:string }} AuthData
6
+ * @typedef {{ name: string, mimetype: string, buffer:Buffer }} Filelike
7
+ */
8
+ /**
9
+ * @param {Array<Filelike>} files
10
+ * @param {AuthData & {
11
+ * name?:string,
12
+ * abort?:AbortSignal,
13
+ * }} opts
14
+ * @returns {Promise<{error:string} | {job_id:string, view_id:string, url?:string | null, skipped?:boolean}>}
15
+ */
16
+ export function uploadFiles(files: Array<Filelike>, opts: AuthData & {
17
+ name?: string;
18
+ abort?: AbortSignal;
19
+ }): Promise<{
20
+ error: string;
21
+ } | {
22
+ job_id: string;
23
+ view_id: string;
24
+ url?: string | null;
25
+ skipped?: boolean;
26
+ }>;
27
+ /**
28
+ * Unfortunately this doesnt get properly bundles in the final output so we have to write the types below directly
29
+ * @typedef {import("@needle-tools/cloud-sdk/types").JobType} JobType
30
+ * @typedef {import("@needle-tools/cloud-sdk/types").JobStatus} JobStatus
31
+ */
32
+ /**
33
+ * @typedef {{
34
+ * name: string,
35
+ * thumbnail_url?: string,
36
+ * created_at: string,
37
+ * updated_at: string,
38
+ * files: Array<{
39
+ * type: "upload" | "conversion" | "optimization" | "deployment",
40
+ * status: "failed" | "completed" | (string & {}),
41
+ * created_at: string,
42
+ * updated_at: string,
43
+ * name? :string,
44
+ * url:string | null,
45
+ * size: number,
46
+ * }>}} Upload
47
+ */
48
+ /**
49
+ * @param {AuthData & ({ name?: string, view_id?:string } | { page: number, limit: number })} opts
50
+ * @returns {Promise<Array<Upload>>}
51
+ */
52
+ export function getUploads(opts: AuthData & ({
53
+ name?: string;
54
+ view_id?: string;
55
+ } | {
56
+ page: number;
57
+ limit: number;
58
+ })): Promise<Array<Upload>>;
59
+ /**
60
+ * @param {AuthData & { offset?:number, limit?: number }} opts
61
+ * @returns {Promise<Array<Deployment>>}
62
+ * @typedef {{ name: string, url: string }} Deployment
63
+ */
64
+ export function getDeployments(opts: AuthData & {
65
+ offset?: number;
66
+ limit?: number;
67
+ }): Promise<Array<Deployment>>;
68
+ export type AuthData = {
69
+ token: string;
70
+ endpoint?: string;
71
+ };
72
+ export type Filelike = {
73
+ name: string;
74
+ mimetype: string;
75
+ buffer: Buffer;
76
+ };
77
+ /**
78
+ * Unfortunately this doesnt get properly bundles in the final output so we have to write the types below directly
79
+ */
80
+ export type JobType = import("@needle-tools/cloud-sdk/types").JobType;
81
+ /**
82
+ * Unfortunately this doesnt get properly bundles in the final output so we have to write the types below directly
83
+ */
84
+ export type JobStatus = import("@needle-tools/cloud-sdk/types").JobStatus;
85
+ export type Upload = {
86
+ name: string;
87
+ thumbnail_url?: string;
88
+ created_at: string;
89
+ updated_at: string;
90
+ files: Array<{
91
+ type: "upload" | "conversion" | "optimization" | "deployment";
92
+ status: "failed" | "completed" | (string & {});
93
+ created_at: string;
94
+ updated_at: string;
95
+ name?: string;
96
+ url: string | null;
97
+ size: number;
98
+ }>;
99
+ };
100
+ export type Deployment = {
101
+ name: string;
102
+ url: string;
103
+ };
@@ -1,103 +1,2 @@
1
- /**
2
- * import("@needle-tools/cloud-sdk/types").FileLike
3
- */
4
- /**
5
- * @typedef {{ token: string, endpoint?:string }} AuthData
6
- * @typedef {{ name: string, mimetype: string, buffer:Buffer }} Filelike
7
- */
8
- /**
9
- * @param {Array<Filelike>} files
10
- * @param {AuthData & {
11
- * name?:string,
12
- * abort?:AbortSignal,
13
- * }} opts
14
- * @returns {Promise<{error:string} | {job_id:string, view_id:string, url?:string, skipped?:boolean}>}
15
- */
16
- export function uploadFiles(files: Array<Filelike>, opts: AuthData & {
17
- name?: string;
18
- abort?: AbortSignal;
19
- }): Promise<{
20
- error: string;
21
- } | {
22
- job_id: string;
23
- view_id: string;
24
- url?: string;
25
- skipped?: boolean;
26
- }>;
27
- /**
28
- * Unfortunately this doesnt get properly bundles in the final output so we have to write the types below directly
29
- * @typedef {import("@needle-tools/cloud-sdk/types").JobType} JobType
30
- * @typedef {import("@needle-tools/cloud-sdk/types").JobStatus} JobStatus
31
- */
32
- /**
33
- * @typedef {{
34
- * name: string,
35
- * thumbnail_url?: string,
36
- * created_at: string,
37
- * updated_at: string,
38
- * files: Array<{
39
- * type: "upload" | "conversion" | "optimization" | "deployment",
40
- * status: "failed" | "completed" | (string & {}),
41
- * created_at: string,
42
- * updated_at: string,
43
- * name? :string,
44
- * url:string | null,
45
- * size: number,
46
- * }>}} Upload
47
- */
48
- /**
49
- * @param {AuthData & ({ name?: string, view_id?:string } | { page: number, limit: number })} opts
50
- * @returns {Promise<Array<Upload>>}
51
- */
52
- export function getUploads(opts: AuthData & ({
53
- name?: string;
54
- view_id?: string;
55
- } | {
56
- page: number;
57
- limit: number;
58
- })): Promise<Array<Upload>>;
59
- /**
60
- * @param {AuthData & { offset?:number, limit?: number }} opts
61
- * @returns {Promise<Array<Deployment>>}
62
- * @typedef {{ name: string, url: string }} Deployment
63
- */
64
- export function getDeployments(opts: AuthData & {
65
- offset?: number;
66
- limit?: number;
67
- }): Promise<Array<Deployment>>;
68
- export type AuthData = {
69
- token: string;
70
- endpoint?: string;
71
- };
72
- export type Filelike = {
73
- name: string;
74
- mimetype: string;
75
- buffer: Buffer;
76
- };
77
- /**
78
- * Unfortunately this doesnt get properly bundles in the final output so we have to write the types below directly
79
- */
80
- export type JobType = import("@needle-tools/cloud-sdk/types").JobType;
81
- /**
82
- * Unfortunately this doesnt get properly bundles in the final output so we have to write the types below directly
83
- */
84
- export type JobStatus = import("@needle-tools/cloud-sdk/types").JobStatus;
85
- export type Upload = {
86
- name: string;
87
- thumbnail_url?: string;
88
- created_at: string;
89
- updated_at: string;
90
- files: Array<{
91
- type: "upload" | "conversion" | "optimization" | "deployment";
92
- status: "failed" | "completed" | (string & {});
93
- created_at: string;
94
- updated_at: string;
95
- name?: string;
96
- url: string | null;
97
- size: number;
98
- }>;
99
- };
100
- export type Deployment = {
101
- name: string;
102
- url: string;
103
- };
1
+ export * from "./auth.js";
2
+ export * from "./functions.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "needle-cloud",
3
- "version": "1.0.0",
3
+ "version": "1.1.0-alpha",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "needle-cloud": "./bin/cli.js"
@@ -13,6 +13,7 @@
13
13
  },
14
14
  "dependencies": {
15
15
  "@caporal/core": "^2.0.7",
16
+ "@logto/browser": "^3.0.7",
16
17
  "@logto/node": "^2.5.8",
17
18
  "@web-std/file": "^3.0.3",
18
19
  "body-parser": "^1.20.3",