dashlyrics 1.0.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/dist/index.d.ts +23 -0
- package/dist/index.js +33 -0
- package/package.json +26 -0
- package/src/index.ts +59 -0
- package/tsconfig.json +16 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface DashLyricsOptions {
|
|
2
|
+
apiKey: string;
|
|
3
|
+
projectKey: string;
|
|
4
|
+
}
|
|
5
|
+
export interface SubmissionPayload {
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
}
|
|
8
|
+
export interface SubmissionResponse {
|
|
9
|
+
success: boolean;
|
|
10
|
+
data?: any;
|
|
11
|
+
error?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare class DashLyrics {
|
|
14
|
+
private apiKey;
|
|
15
|
+
private projectKey;
|
|
16
|
+
private baseUrl;
|
|
17
|
+
constructor(options: DashLyricsOptions);
|
|
18
|
+
/**
|
|
19
|
+
* Submit structured data to your DashLyrics backend.
|
|
20
|
+
* Automatically includes apiKey + projectKey for validation.
|
|
21
|
+
*/
|
|
22
|
+
submit(data: SubmissionPayload): Promise<SubmissionResponse>;
|
|
23
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
export class DashLyrics {
|
|
3
|
+
constructor(options) {
|
|
4
|
+
this.baseUrl = "http://localhost:3000"; // fixed internal base URL
|
|
5
|
+
if (!options.apiKey)
|
|
6
|
+
throw new Error("API key is required");
|
|
7
|
+
if (!options.projectKey)
|
|
8
|
+
throw new Error("Project key is required");
|
|
9
|
+
this.apiKey = options.apiKey;
|
|
10
|
+
this.projectKey = options.projectKey;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Submit structured data to your DashLyrics backend.
|
|
14
|
+
* Automatically includes apiKey + projectKey for validation.
|
|
15
|
+
*/
|
|
16
|
+
async submit(data) {
|
|
17
|
+
try {
|
|
18
|
+
const response = await axios.post(`${this.baseUrl}/api/datasubmit`, {
|
|
19
|
+
api_key: this.apiKey,
|
|
20
|
+
project_key: this.projectKey,
|
|
21
|
+
submission_data: data,
|
|
22
|
+
});
|
|
23
|
+
return response.data;
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
console.error("[DashLyrics SDK] Submission failed:", error.response?.data || error.message);
|
|
27
|
+
return {
|
|
28
|
+
success: false,
|
|
29
|
+
error: error.response?.data?.error || "Submission failed",
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "dashlyrics",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "SDK for submitting project data to DashLyrics backend",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"test": "node test/test.js"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"sdk",
|
|
13
|
+
"dashlyrics",
|
|
14
|
+
"axios",
|
|
15
|
+
"submission"
|
|
16
|
+
],
|
|
17
|
+
"author": "",
|
|
18
|
+
"license": "ISC",
|
|
19
|
+
"type": "module",
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"typescript": "^5.9.3"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"axios": "^1.6.8"
|
|
25
|
+
}
|
|
26
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
|
|
3
|
+
export interface DashLyricsOptions {
|
|
4
|
+
apiKey: string;
|
|
5
|
+
projectKey: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface SubmissionPayload {
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface SubmissionResponse {
|
|
13
|
+
success: boolean;
|
|
14
|
+
data?: any;
|
|
15
|
+
error?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export class DashLyrics {
|
|
19
|
+
private apiKey: string;
|
|
20
|
+
private projectKey: string;
|
|
21
|
+
private baseUrl: string = "http://localhost:3000"; // fixed internal base URL
|
|
22
|
+
|
|
23
|
+
constructor(options: DashLyricsOptions) {
|
|
24
|
+
if (!options.apiKey) throw new Error("API key is required");
|
|
25
|
+
if (!options.projectKey) throw new Error("Project key is required");
|
|
26
|
+
|
|
27
|
+
this.apiKey = options.apiKey;
|
|
28
|
+
this.projectKey = options.projectKey;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Submit structured data to your DashLyrics backend.
|
|
33
|
+
* Automatically includes apiKey + projectKey for validation.
|
|
34
|
+
*/
|
|
35
|
+
async submit(data: SubmissionPayload): Promise<SubmissionResponse> {
|
|
36
|
+
try {
|
|
37
|
+
const response = await axios.post(`${this.baseUrl}/api/datasubmit`, {
|
|
38
|
+
api_key: this.apiKey,
|
|
39
|
+
project_key: this.projectKey,
|
|
40
|
+
submission_data: data,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
return response.data;
|
|
44
|
+
} catch (error: any) {
|
|
45
|
+
console.error(
|
|
46
|
+
"[DashLyrics SDK] Submission failed:",
|
|
47
|
+
error.response?.data || error.message
|
|
48
|
+
);
|
|
49
|
+
return {
|
|
50
|
+
success: false,
|
|
51
|
+
error: error.response?.data?.error || "Submission failed",
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Optional helper to test if SDK is configured properly.
|
|
58
|
+
*/
|
|
59
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
// Visit https://aka.ms/tsconfig to read more about this file
|
|
3
|
+
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"target": "ES2020",
|
|
6
|
+
"module": "ESNext",
|
|
7
|
+
"moduleResolution": "Node",
|
|
8
|
+
"declaration": true,
|
|
9
|
+
"outDir": "dist",
|
|
10
|
+
"rootDir": "src",
|
|
11
|
+
"esModuleInterop": true,
|
|
12
|
+
"strict": true,
|
|
13
|
+
"skipLibCheck": true
|
|
14
|
+
},
|
|
15
|
+
"include": ["src/**/*"]
|
|
16
|
+
}
|