( filename: string, contents: string, options?: CreateJsonOptions )
| 81 | } |
| 82 | |
| 83 | export async function createFromRawJson( |
| 84 | filename: string, |
| 85 | contents: string, |
| 86 | options?: CreateJsonOptions |
| 87 | ): Promise<JSONDocument> { |
| 88 | const docId = createId(); |
| 89 | const doc: JSONDocument = { |
| 90 | id: docId, |
| 91 | type: <const>"raw", |
| 92 | contents, |
| 93 | title: filename, |
| 94 | readOnly: options?.readOnly ?? false, |
| 95 | }; |
| 96 | |
| 97 | JSON.parse(contents); |
| 98 | await DOCUMENTS.put(docId, JSON.stringify(doc), { |
| 99 | expirationTtl: options?.ttl ?? undefined, |
| 100 | metadata: options?.metadata ?? undefined, |
| 101 | }); |
| 102 | |
| 103 | return doc; |
| 104 | } |
| 105 | |
| 106 | export async function getDocument( |
| 107 | slug: string |
no test coverage detected