yt-transcript-strapi-plugin 0.0.22 → 0.0.26
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/server/index.js +437 -36
- package/dist/server/index.mjs +437 -36
- package/dist/server/src/config/index.d.ts +8 -8
- package/dist/server/src/index.d.ts +10 -19
- package/dist/server/src/mcp/schemas/index.d.ts +63 -0
- package/dist/server/src/mcp/tools/get-transcript.d.ts +26 -0
- package/dist/server/src/mcp/tools/search-transcript.d.ts +30 -0
- package/dist/server/src/routes/content-api.d.ts +2 -11
- package/dist/server/src/routes/index.d.ts +2 -11
- package/node_modules/which/CHANGELOG.md +166 -0
- package/package.json +7 -2
- package/node_modules/express/node_modules/media-typer/HISTORY.md +0 -50
- package/node_modules/express/node_modules/media-typer/LICENSE +0 -22
- package/node_modules/express/node_modules/media-typer/README.md +0 -93
- package/node_modules/express/node_modules/media-typer/index.js +0 -143
- package/node_modules/express/node_modules/media-typer/package.json +0 -33
- package/node_modules/express/node_modules/type-is/HISTORY.md +0 -292
- package/node_modules/express/node_modules/type-is/LICENSE +0 -23
- package/node_modules/express/node_modules/type-is/README.md +0 -198
- package/node_modules/express/node_modules/type-is/index.js +0 -250
- package/node_modules/express/node_modules/type-is/package.json +0 -47
- /package/node_modules/{body-parser/node_modules/media-typer → media-typer}/HISTORY.md +0 -0
- /package/node_modules/{body-parser/node_modules/media-typer → media-typer}/LICENSE +0 -0
- /package/node_modules/{body-parser/node_modules/media-typer → media-typer}/README.md +0 -0
- /package/node_modules/{body-parser/node_modules/media-typer → media-typer}/index.js +0 -0
- /package/node_modules/{body-parser/node_modules/media-typer → media-typer}/package.json +0 -0
- /package/node_modules/{body-parser/node_modules/type-is → type-is}/HISTORY.md +0 -0
- /package/node_modules/{body-parser/node_modules/type-is → type-is}/LICENSE +0 -0
- /package/node_modules/{body-parser/node_modules/type-is → type-is}/README.md +0 -0
- /package/node_modules/{body-parser/node_modules/type-is → type-is}/index.js +0 -0
- /package/node_modules/{body-parser → type-is}/node_modules/mime-types/HISTORY.md +0 -0
- /package/node_modules/{body-parser → type-is}/node_modules/mime-types/LICENSE +0 -0
- /package/node_modules/{body-parser → type-is}/node_modules/mime-types/README.md +0 -0
- /package/node_modules/{body-parser → type-is}/node_modules/mime-types/index.js +0 -0
- /package/node_modules/{body-parser → type-is}/node_modules/mime-types/mimeScore.js +0 -0
- /package/node_modules/{body-parser → type-is}/node_modules/mime-types/package.json +0 -0
- /package/node_modules/{body-parser/node_modules/type-is → type-is}/package.json +0 -0
|
@@ -21,10 +21,41 @@ export declare const ListTranscriptsSchema: z.ZodObject<{
|
|
|
21
21
|
}>;
|
|
22
22
|
export declare const GetTranscriptSchema: z.ZodObject<{
|
|
23
23
|
videoId: z.ZodString;
|
|
24
|
+
includeFullTranscript: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
25
|
+
includeTimecodes: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
26
|
+
startTime: z.ZodOptional<z.ZodNumber>;
|
|
27
|
+
endTime: z.ZodOptional<z.ZodNumber>;
|
|
28
|
+
chunkIndex: z.ZodOptional<z.ZodNumber>;
|
|
29
|
+
chunkSize: z.ZodOptional<z.ZodNumber>;
|
|
24
30
|
}, "strip", z.ZodTypeAny, {
|
|
25
31
|
videoId?: string;
|
|
32
|
+
includeFullTranscript?: boolean;
|
|
33
|
+
includeTimecodes?: boolean;
|
|
34
|
+
startTime?: number;
|
|
35
|
+
endTime?: number;
|
|
36
|
+
chunkIndex?: number;
|
|
37
|
+
chunkSize?: number;
|
|
26
38
|
}, {
|
|
27
39
|
videoId?: string;
|
|
40
|
+
includeFullTranscript?: boolean;
|
|
41
|
+
includeTimecodes?: boolean;
|
|
42
|
+
startTime?: number;
|
|
43
|
+
endTime?: number;
|
|
44
|
+
chunkIndex?: number;
|
|
45
|
+
chunkSize?: number;
|
|
46
|
+
}>;
|
|
47
|
+
export declare const SearchTranscriptSchema: z.ZodObject<{
|
|
48
|
+
videoId: z.ZodString;
|
|
49
|
+
query: z.ZodString;
|
|
50
|
+
maxResults: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
51
|
+
}, "strip", z.ZodTypeAny, {
|
|
52
|
+
videoId?: string;
|
|
53
|
+
query?: string;
|
|
54
|
+
maxResults?: number;
|
|
55
|
+
}, {
|
|
56
|
+
videoId?: string;
|
|
57
|
+
query?: string;
|
|
58
|
+
maxResults?: number;
|
|
28
59
|
}>;
|
|
29
60
|
export declare const FindTranscriptsSchema: z.ZodObject<{
|
|
30
61
|
query: z.ZodOptional<z.ZodString>;
|
|
@@ -54,6 +85,7 @@ export declare const FindTranscriptsSchema: z.ZodObject<{
|
|
|
54
85
|
export type FetchTranscriptInput = z.infer<typeof FetchTranscriptSchema>;
|
|
55
86
|
export type ListTranscriptsInput = z.infer<typeof ListTranscriptsSchema>;
|
|
56
87
|
export type GetTranscriptInput = z.infer<typeof GetTranscriptSchema>;
|
|
88
|
+
export type SearchTranscriptInput = z.infer<typeof SearchTranscriptSchema>;
|
|
57
89
|
export type FindTranscriptsInput = z.infer<typeof FindTranscriptsSchema>;
|
|
58
90
|
export declare const ToolSchemas: {
|
|
59
91
|
readonly fetch_transcript: z.ZodObject<{
|
|
@@ -78,10 +110,41 @@ export declare const ToolSchemas: {
|
|
|
78
110
|
}>;
|
|
79
111
|
readonly get_transcript: z.ZodObject<{
|
|
80
112
|
videoId: z.ZodString;
|
|
113
|
+
includeFullTranscript: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
114
|
+
includeTimecodes: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
115
|
+
startTime: z.ZodOptional<z.ZodNumber>;
|
|
116
|
+
endTime: z.ZodOptional<z.ZodNumber>;
|
|
117
|
+
chunkIndex: z.ZodOptional<z.ZodNumber>;
|
|
118
|
+
chunkSize: z.ZodOptional<z.ZodNumber>;
|
|
81
119
|
}, "strip", z.ZodTypeAny, {
|
|
82
120
|
videoId?: string;
|
|
121
|
+
includeFullTranscript?: boolean;
|
|
122
|
+
includeTimecodes?: boolean;
|
|
123
|
+
startTime?: number;
|
|
124
|
+
endTime?: number;
|
|
125
|
+
chunkIndex?: number;
|
|
126
|
+
chunkSize?: number;
|
|
83
127
|
}, {
|
|
84
128
|
videoId?: string;
|
|
129
|
+
includeFullTranscript?: boolean;
|
|
130
|
+
includeTimecodes?: boolean;
|
|
131
|
+
startTime?: number;
|
|
132
|
+
endTime?: number;
|
|
133
|
+
chunkIndex?: number;
|
|
134
|
+
chunkSize?: number;
|
|
135
|
+
}>;
|
|
136
|
+
readonly search_transcript: z.ZodObject<{
|
|
137
|
+
videoId: z.ZodString;
|
|
138
|
+
query: z.ZodString;
|
|
139
|
+
maxResults: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
140
|
+
}, "strip", z.ZodTypeAny, {
|
|
141
|
+
videoId?: string;
|
|
142
|
+
query?: string;
|
|
143
|
+
maxResults?: number;
|
|
144
|
+
}, {
|
|
145
|
+
videoId?: string;
|
|
146
|
+
query?: string;
|
|
147
|
+
maxResults?: number;
|
|
85
148
|
}>;
|
|
86
149
|
readonly find_transcripts: z.ZodObject<{
|
|
87
150
|
query: z.ZodOptional<z.ZodString>;
|
|
@@ -9,6 +9,32 @@ export declare const getTranscriptTool: {
|
|
|
9
9
|
type: string;
|
|
10
10
|
description: string;
|
|
11
11
|
};
|
|
12
|
+
includeFullTranscript: {
|
|
13
|
+
type: string;
|
|
14
|
+
description: string;
|
|
15
|
+
default: boolean;
|
|
16
|
+
};
|
|
17
|
+
includeTimecodes: {
|
|
18
|
+
type: string;
|
|
19
|
+
description: string;
|
|
20
|
+
default: boolean;
|
|
21
|
+
};
|
|
22
|
+
startTime: {
|
|
23
|
+
type: string;
|
|
24
|
+
description: string;
|
|
25
|
+
};
|
|
26
|
+
endTime: {
|
|
27
|
+
type: string;
|
|
28
|
+
description: string;
|
|
29
|
+
};
|
|
30
|
+
chunkIndex: {
|
|
31
|
+
type: string;
|
|
32
|
+
description: string;
|
|
33
|
+
};
|
|
34
|
+
chunkSize: {
|
|
35
|
+
type: string;
|
|
36
|
+
description: string;
|
|
37
|
+
};
|
|
12
38
|
};
|
|
13
39
|
required: string[];
|
|
14
40
|
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Core } from '@strapi/strapi';
|
|
2
|
+
export declare const searchTranscriptTool: {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
inputSchema: {
|
|
6
|
+
type: "object";
|
|
7
|
+
properties: {
|
|
8
|
+
videoId: {
|
|
9
|
+
type: string;
|
|
10
|
+
description: string;
|
|
11
|
+
};
|
|
12
|
+
query: {
|
|
13
|
+
type: string;
|
|
14
|
+
description: string;
|
|
15
|
+
};
|
|
16
|
+
maxResults: {
|
|
17
|
+
type: string;
|
|
18
|
+
description: string;
|
|
19
|
+
default: number;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
required: string[];
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export declare function handleSearchTranscript(strapi: Core.Strapi, args: unknown): Promise<{
|
|
26
|
+
content: {
|
|
27
|
+
type: "text";
|
|
28
|
+
text: string;
|
|
29
|
+
}[];
|
|
30
|
+
}>;
|
|
@@ -1,18 +1,9 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: {
|
|
2
2
|
method: string;
|
|
3
3
|
path: string;
|
|
4
4
|
handler: string;
|
|
5
5
|
config: {
|
|
6
6
|
policies: any[];
|
|
7
|
-
auth: boolean;
|
|
8
7
|
};
|
|
9
|
-
}
|
|
10
|
-
method: string;
|
|
11
|
-
path: string;
|
|
12
|
-
handler: string;
|
|
13
|
-
config: {
|
|
14
|
-
policies: any[];
|
|
15
|
-
auth?: undefined;
|
|
16
|
-
};
|
|
17
|
-
})[];
|
|
8
|
+
}[];
|
|
18
9
|
export default _default;
|
|
@@ -1,23 +1,14 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
2
|
"content-api": {
|
|
3
3
|
type: string;
|
|
4
|
-
routes:
|
|
5
|
-
method: string;
|
|
6
|
-
path: string;
|
|
7
|
-
handler: string;
|
|
8
|
-
config: {
|
|
9
|
-
policies: any[];
|
|
10
|
-
auth: boolean;
|
|
11
|
-
};
|
|
12
|
-
} | {
|
|
4
|
+
routes: {
|
|
13
5
|
method: string;
|
|
14
6
|
path: string;
|
|
15
7
|
handler: string;
|
|
16
8
|
config: {
|
|
17
9
|
policies: any[];
|
|
18
|
-
auth?: undefined;
|
|
19
10
|
};
|
|
20
|
-
}
|
|
11
|
+
}[];
|
|
21
12
|
};
|
|
22
13
|
admin: {
|
|
23
14
|
type: string;
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# Changes
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
## 2.0.2
|
|
5
|
+
|
|
6
|
+
* Rename bin to `node-which`
|
|
7
|
+
|
|
8
|
+
## 2.0.1
|
|
9
|
+
|
|
10
|
+
* generate changelog and publish on version bump
|
|
11
|
+
* enforce 100% test coverage
|
|
12
|
+
* Promise interface
|
|
13
|
+
|
|
14
|
+
## 2.0.0
|
|
15
|
+
|
|
16
|
+
* Parallel tests, modern JavaScript, and drop support for node < 8
|
|
17
|
+
|
|
18
|
+
## 1.3.1
|
|
19
|
+
|
|
20
|
+
* update deps
|
|
21
|
+
* update travis
|
|
22
|
+
|
|
23
|
+
## v1.3.0
|
|
24
|
+
|
|
25
|
+
* Add nothrow option to which.sync
|
|
26
|
+
* update tap
|
|
27
|
+
|
|
28
|
+
## v1.2.14
|
|
29
|
+
|
|
30
|
+
* appveyor: drop node 5 and 0.x
|
|
31
|
+
* travis-ci: add node 6, drop 0.x
|
|
32
|
+
|
|
33
|
+
## v1.2.13
|
|
34
|
+
|
|
35
|
+
* test: Pass missing option to pass on windows
|
|
36
|
+
* update tap
|
|
37
|
+
* update isexe to 2.0.0
|
|
38
|
+
* neveragain.tech pledge request
|
|
39
|
+
|
|
40
|
+
## v1.2.12
|
|
41
|
+
|
|
42
|
+
* Removed unused require
|
|
43
|
+
|
|
44
|
+
## v1.2.11
|
|
45
|
+
|
|
46
|
+
* Prevent changelog script from being included in package
|
|
47
|
+
|
|
48
|
+
## v1.2.10
|
|
49
|
+
|
|
50
|
+
* Use env.PATH only, not env.Path
|
|
51
|
+
|
|
52
|
+
## v1.2.9
|
|
53
|
+
|
|
54
|
+
* fix for paths starting with ../
|
|
55
|
+
* Remove unused `is-absolute` module
|
|
56
|
+
|
|
57
|
+
## v1.2.8
|
|
58
|
+
|
|
59
|
+
* bullet items in changelog that contain (but don't start with) #
|
|
60
|
+
|
|
61
|
+
## v1.2.7
|
|
62
|
+
|
|
63
|
+
* strip 'update changelog' changelog entries out of changelog
|
|
64
|
+
|
|
65
|
+
## v1.2.6
|
|
66
|
+
|
|
67
|
+
* make the changelog bulleted
|
|
68
|
+
|
|
69
|
+
## v1.2.5
|
|
70
|
+
|
|
71
|
+
* make a changelog, and keep it up to date
|
|
72
|
+
* don't include tests in package
|
|
73
|
+
* Properly handle relative-path executables
|
|
74
|
+
* appveyor
|
|
75
|
+
* Attach error code to Not Found error
|
|
76
|
+
* Make tests pass on Windows
|
|
77
|
+
|
|
78
|
+
## v1.2.4
|
|
79
|
+
|
|
80
|
+
* Fix typo
|
|
81
|
+
|
|
82
|
+
## v1.2.3
|
|
83
|
+
|
|
84
|
+
* update isexe, fix regression in pathExt handling
|
|
85
|
+
|
|
86
|
+
## v1.2.2
|
|
87
|
+
|
|
88
|
+
* update deps, use isexe module, test windows
|
|
89
|
+
|
|
90
|
+
## v1.2.1
|
|
91
|
+
|
|
92
|
+
* Sometimes windows PATH entries are quoted
|
|
93
|
+
* Fixed a bug in the check for group and user mode bits. This bug was introduced during refactoring for supporting strict mode.
|
|
94
|
+
* doc cli
|
|
95
|
+
|
|
96
|
+
## v1.2.0
|
|
97
|
+
|
|
98
|
+
* Add support for opt.all and -as cli flags
|
|
99
|
+
* test the bin
|
|
100
|
+
* update travis
|
|
101
|
+
* Allow checking for multiple programs in bin/which
|
|
102
|
+
* tap 2
|
|
103
|
+
|
|
104
|
+
## v1.1.2
|
|
105
|
+
|
|
106
|
+
* travis
|
|
107
|
+
* Refactored and fixed undefined error on Windows
|
|
108
|
+
* Support strict mode
|
|
109
|
+
|
|
110
|
+
## v1.1.1
|
|
111
|
+
|
|
112
|
+
* test +g exes against secondary groups, if available
|
|
113
|
+
* Use windows exe semantics on cygwin & msys
|
|
114
|
+
* cwd should be first in path on win32, not last
|
|
115
|
+
* Handle lower-case 'env.Path' on Windows
|
|
116
|
+
* Update docs
|
|
117
|
+
* use single-quotes
|
|
118
|
+
|
|
119
|
+
## v1.1.0
|
|
120
|
+
|
|
121
|
+
* Add tests, depend on is-absolute
|
|
122
|
+
|
|
123
|
+
## v1.0.9
|
|
124
|
+
|
|
125
|
+
* which.js: root is allowed to execute files owned by anyone
|
|
126
|
+
|
|
127
|
+
## v1.0.8
|
|
128
|
+
|
|
129
|
+
* don't use graceful-fs
|
|
130
|
+
|
|
131
|
+
## v1.0.7
|
|
132
|
+
|
|
133
|
+
* add license to package.json
|
|
134
|
+
|
|
135
|
+
## v1.0.6
|
|
136
|
+
|
|
137
|
+
* isc license
|
|
138
|
+
|
|
139
|
+
## 1.0.5
|
|
140
|
+
|
|
141
|
+
* Awful typo
|
|
142
|
+
|
|
143
|
+
## 1.0.4
|
|
144
|
+
|
|
145
|
+
* Test for path absoluteness properly
|
|
146
|
+
* win: Allow '' as a pathext if cmd has a . in it
|
|
147
|
+
|
|
148
|
+
## 1.0.3
|
|
149
|
+
|
|
150
|
+
* Remove references to execPath
|
|
151
|
+
* Make `which.sync()` work on Windows by honoring the PATHEXT variable.
|
|
152
|
+
* Make `isExe()` always return true on Windows.
|
|
153
|
+
* MIT
|
|
154
|
+
|
|
155
|
+
## 1.0.2
|
|
156
|
+
|
|
157
|
+
* Only files can be exes
|
|
158
|
+
|
|
159
|
+
## 1.0.1
|
|
160
|
+
|
|
161
|
+
* Respect the PATHEXT env for win32 support
|
|
162
|
+
* should 0755 the bin
|
|
163
|
+
* binary
|
|
164
|
+
* guts
|
|
165
|
+
* package
|
|
166
|
+
* 1st
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.0.
|
|
2
|
+
"version": "0.0.26",
|
|
3
3
|
"keywords": [
|
|
4
4
|
"yt-transcript-strapi-plugin",
|
|
5
5
|
"youtube",
|
|
@@ -39,7 +39,10 @@
|
|
|
39
39
|
"watch:link": "strapi-plugin watch:link",
|
|
40
40
|
"verify": "strapi-plugin verify",
|
|
41
41
|
"test:ts:front": "run -T tsc -p admin/tsconfig.json",
|
|
42
|
-
"test:ts:back": "run -T tsc -p server/tsconfig.json"
|
|
42
|
+
"test:ts:back": "run -T tsc -p server/tsconfig.json",
|
|
43
|
+
"test:mcp": "npx ts-node --project scripts/tsconfig.json scripts/test-mcp.ts",
|
|
44
|
+
"test:mcp:local": "npx ts-node --project scripts/tsconfig.json scripts/test-mcp.ts http://localhost:1337",
|
|
45
|
+
"test:mcp:prod": "npx ts-node --project scripts/tsconfig.json scripts/test-mcp.ts https://deserving-harmony-9f5ca04daf.strapiapp.com"
|
|
43
46
|
},
|
|
44
47
|
"dependencies": {
|
|
45
48
|
"@modelcontextprotocol/sdk": "^1.12.0",
|
|
@@ -58,6 +61,7 @@
|
|
|
58
61
|
"@strapi/sdk-plugin": "^5.3.2",
|
|
59
62
|
"@strapi/strapi": "^5.33.0",
|
|
60
63
|
"@strapi/typescript-utils": "^5.33.0",
|
|
64
|
+
"@types/node": "^20.0.0",
|
|
61
65
|
"@types/react": "^18.3.12",
|
|
62
66
|
"@types/react-dom": "^18.3.1",
|
|
63
67
|
"prettier": "^3.3.3",
|
|
@@ -65,6 +69,7 @@
|
|
|
65
69
|
"react-dom": "^18.3.1",
|
|
66
70
|
"react-router-dom": "^6.28.0",
|
|
67
71
|
"styled-components": "^6.1.13",
|
|
72
|
+
"ts-node": "^10.9.2",
|
|
68
73
|
"typescript": "^5.6.3"
|
|
69
74
|
},
|
|
70
75
|
"peerDependencies": {
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
1.1.0 / 2019-04-24
|
|
2
|
-
==================
|
|
3
|
-
|
|
4
|
-
* Add `test(string)` function
|
|
5
|
-
|
|
6
|
-
1.0.2 / 2019-04-19
|
|
7
|
-
==================
|
|
8
|
-
|
|
9
|
-
* Fix JSDoc comment for `parse` function
|
|
10
|
-
|
|
11
|
-
1.0.1 / 2018-10-20
|
|
12
|
-
==================
|
|
13
|
-
|
|
14
|
-
* Remove left over `parameters` property from class
|
|
15
|
-
|
|
16
|
-
1.0.0 / 2018-10-20
|
|
17
|
-
==================
|
|
18
|
-
|
|
19
|
-
This major release brings the module back to it's RFC 6838 roots. If you want
|
|
20
|
-
a module to parse the `Content-Type` or similar HTTP headers, use the
|
|
21
|
-
`content-type` module instead.
|
|
22
|
-
|
|
23
|
-
* Drop support for Node.js below 0.8
|
|
24
|
-
* Remove parameter handling, which is outside RFC 6838 scope
|
|
25
|
-
* Remove `parse(req)` and `parse(res)` signatures
|
|
26
|
-
* perf: enable strict mode
|
|
27
|
-
* perf: use a class for object creation
|
|
28
|
-
|
|
29
|
-
0.3.0 / 2014-09-07
|
|
30
|
-
==================
|
|
31
|
-
|
|
32
|
-
* Support Node.js 0.6
|
|
33
|
-
* Throw error when parameter format invalid on parse
|
|
34
|
-
|
|
35
|
-
0.2.0 / 2014-06-18
|
|
36
|
-
==================
|
|
37
|
-
|
|
38
|
-
* Add `typer.format()` to format media types
|
|
39
|
-
|
|
40
|
-
0.1.0 / 2014-06-17
|
|
41
|
-
==================
|
|
42
|
-
|
|
43
|
-
* Accept `req` as argument to `parse`
|
|
44
|
-
* Accept `res` as argument to `parse`
|
|
45
|
-
* Parse media type with extra LWS between type and first parameter
|
|
46
|
-
|
|
47
|
-
0.0.0 / 2014-06-13
|
|
48
|
-
==================
|
|
49
|
-
|
|
50
|
-
* Initial implementation
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
(The MIT License)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2014-2017 Douglas Christopher Wilson
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
-
a copy of this software and associated documentation files (the
|
|
7
|
-
'Software'), to deal in the Software without restriction, including
|
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
-
the following conditions:
|
|
12
|
-
|
|
13
|
-
The above copyright notice and this permission notice shall be
|
|
14
|
-
included in all copies or substantial portions of the Software.
|
|
15
|
-
|
|
16
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
# media-typer
|
|
2
|
-
|
|
3
|
-
[![NPM Version][npm-version-image]][npm-url]
|
|
4
|
-
[![NPM Downloads][npm-downloads-image]][npm-url]
|
|
5
|
-
[![Node.js Version][node-version-image]][node-version-url]
|
|
6
|
-
[![Build Status][travis-image]][travis-url]
|
|
7
|
-
[![Test Coverage][coveralls-image]][coveralls-url]
|
|
8
|
-
|
|
9
|
-
Simple RFC 6838 media type parser.
|
|
10
|
-
|
|
11
|
-
This module will parse a given media type into it's component parts, like type,
|
|
12
|
-
subtype, and suffix. A formatter is also provided to put them back together and
|
|
13
|
-
the two can be combined to normalize media types into a canonical form.
|
|
14
|
-
|
|
15
|
-
If you are looking to parse the string that represents a media type and it's
|
|
16
|
-
parameters in HTTP (for example, the `Content-Type` header), use the
|
|
17
|
-
[content-type module](https://www.npmjs.com/package/content-type).
|
|
18
|
-
|
|
19
|
-
## Installation
|
|
20
|
-
|
|
21
|
-
This is a [Node.js](https://nodejs.org/en/) module available through the
|
|
22
|
-
[npm registry](https://www.npmjs.com/). Installation is done using the
|
|
23
|
-
[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
|
|
24
|
-
|
|
25
|
-
```sh
|
|
26
|
-
$ npm install media-typer
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
## API
|
|
30
|
-
|
|
31
|
-
<!-- eslint-disable no-unused-vars -->
|
|
32
|
-
|
|
33
|
-
```js
|
|
34
|
-
var typer = require('media-typer')
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
### typer.parse(string)
|
|
38
|
-
|
|
39
|
-
<!-- eslint-disable no-undef, no-unused-vars -->
|
|
40
|
-
|
|
41
|
-
```js
|
|
42
|
-
var obj = typer.parse('image/svg+xml')
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
Parse a media type string. This will return an object with the following
|
|
46
|
-
properties (examples are shown for the string `'image/svg+xml; charset=utf-8'`):
|
|
47
|
-
|
|
48
|
-
- `type`: The type of the media type (always lower case). Example: `'image'`
|
|
49
|
-
|
|
50
|
-
- `subtype`: The subtype of the media type (always lower case). Example: `'svg'`
|
|
51
|
-
|
|
52
|
-
- `suffix`: The suffix of the media type (always lower case). Example: `'xml'`
|
|
53
|
-
|
|
54
|
-
If the given type string is invalid, then a `TypeError` is thrown.
|
|
55
|
-
|
|
56
|
-
### typer.format(obj)
|
|
57
|
-
|
|
58
|
-
<!-- eslint-disable no-undef, no-unused-vars -->
|
|
59
|
-
|
|
60
|
-
```js
|
|
61
|
-
var obj = typer.format({ type: 'image', subtype: 'svg', suffix: 'xml' })
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
Format an object into a media type string. This will return a string of the
|
|
65
|
-
mime type for the given object. For the properties of the object, see the
|
|
66
|
-
documentation for `typer.parse(string)`.
|
|
67
|
-
|
|
68
|
-
If any of the given object values are invalid, then a `TypeError` is thrown.
|
|
69
|
-
|
|
70
|
-
### typer.test(string)
|
|
71
|
-
|
|
72
|
-
<!-- eslint-disable no-undef, no-unused-vars -->
|
|
73
|
-
|
|
74
|
-
```js
|
|
75
|
-
var valid = typer.test('image/svg+xml')
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
Validate a media type string. This will return `true` is the string is a well-
|
|
79
|
-
formatted media type, or `false` otherwise.
|
|
80
|
-
|
|
81
|
-
## License
|
|
82
|
-
|
|
83
|
-
[MIT](LICENSE)
|
|
84
|
-
|
|
85
|
-
[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/media-typer/master
|
|
86
|
-
[coveralls-url]: https://coveralls.io/r/jshttp/media-typer?branch=master
|
|
87
|
-
[node-version-image]: https://badgen.net/npm/node/media-typer
|
|
88
|
-
[node-version-url]: https://nodejs.org/en/download
|
|
89
|
-
[npm-downloads-image]: https://badgen.net/npm/dm/media-typer
|
|
90
|
-
[npm-url]: https://npmjs.org/package/media-typer
|
|
91
|
-
[npm-version-image]: https://badgen.net/npm/v/media-typer
|
|
92
|
-
[travis-image]: https://badgen.net/travis/jshttp/media-typer/master
|
|
93
|
-
[travis-url]: https://travis-ci.org/jshttp/media-typer
|