@meeovi/layer-lists 1.0.8 → 1.0.10
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/package.json +3 -3
- package/tsconfig.json +0 -1
- package/app/composables/globals/useDirectusForm.ts +0 -1
- package/app/composables/providers/atproto.ts +0 -156
- package/global.d.ts +0 -1
- package/index.js +0 -3
- package/shims.d.ts +0 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meeovi/layer-lists",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"description": "Official Lists module for the M Framework.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "tsc -p tsconfig.json",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"main": "./nuxt.config.ts",
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@meeovi/api": "^1.0.1",
|
|
21
|
-
"@meeovi/core": "^1.0.
|
|
21
|
+
"@meeovi/core": "^1.0.4",
|
|
22
22
|
"@meeovi/directus-client": "^1.0.0",
|
|
23
23
|
"@meeovi/layer-social": "^1.0.2",
|
|
24
24
|
"list.js": "^2.3.1",
|
|
@@ -27,4 +27,4 @@
|
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"nuxt": "^4.3.0"
|
|
29
29
|
}
|
|
30
|
-
}
|
|
30
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '#shared/app/composables/globals/useDirectusForm'
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import { registerListsProvider } from '../registry'
|
|
2
|
-
import type { ListsProvider, List, ListItem } from '../types'
|
|
3
|
-
import { wrapSocialRequest } from '@meeovi/social'
|
|
4
|
-
import { transformList, transformItem } from '../utils/transforms'
|
|
5
|
-
import { validateListInput, validateItemInput } from '../utils/validation'
|
|
6
|
-
import { getListsConfig } from '../config'
|
|
7
|
-
|
|
8
|
-
async function atprotoFetch(path: string, options: RequestInit = {}) {
|
|
9
|
-
const { baseUrl, apiKey } = getListsConfig()
|
|
10
|
-
|
|
11
|
-
const res = await fetch(`${baseUrl}${path}`, {
|
|
12
|
-
...options,
|
|
13
|
-
headers: {
|
|
14
|
-
'Content-Type': 'application/json',
|
|
15
|
-
...(apiKey ? { Authorization: `Bearer ${apiKey}` } : {}),
|
|
16
|
-
...(options.headers || {})
|
|
17
|
-
}
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
if (!res.ok) {
|
|
21
|
-
const error: any = new Error(`ATProto error: ${res.status}`)
|
|
22
|
-
error.status = res.status
|
|
23
|
-
error.response = res
|
|
24
|
-
throw error
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return res.json()
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const AtprotoListsProvider: ListsProvider = {
|
|
31
|
-
async getList(id) {
|
|
32
|
-
return wrapSocialRequest('atproto', async () => {
|
|
33
|
-
const data = await atprotoFetch(`/xrpc/app.bsky.graph.getList?list=${id}`)
|
|
34
|
-
return transformList(data.list)
|
|
35
|
-
}, {
|
|
36
|
-
cacheKey: `atproto:list:${id}`,
|
|
37
|
-
ttlMs: 1000 * 30,
|
|
38
|
-
retry: true,
|
|
39
|
-
swr: true
|
|
40
|
-
})
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
async listLists() {
|
|
44
|
-
return wrapSocialRequest('atproto', async () => {
|
|
45
|
-
const data = await atprotoFetch(`/xrpc/app.bsky.graph.getLists`)
|
|
46
|
-
return data.lists.map(transformList)
|
|
47
|
-
}, {
|
|
48
|
-
cacheKey: `atproto:lists`,
|
|
49
|
-
ttlMs: 1000 * 30,
|
|
50
|
-
retry: true,
|
|
51
|
-
swr: true
|
|
52
|
-
})
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
async createList(data) {
|
|
56
|
-
validateListInput(data)
|
|
57
|
-
|
|
58
|
-
return wrapSocialRequest('atproto', async () => {
|
|
59
|
-
const result = await atprotoFetch(`/xrpc/app.bsky.graph.createList`, {
|
|
60
|
-
method: 'POST',
|
|
61
|
-
body: JSON.stringify({
|
|
62
|
-
name: data.title,
|
|
63
|
-
purpose: data.type ?? 'list',
|
|
64
|
-
description: data.metadata?.description ?? ''
|
|
65
|
-
})
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
return transformList(result)
|
|
69
|
-
})
|
|
70
|
-
},
|
|
71
|
-
|
|
72
|
-
async updateList(id, data) {
|
|
73
|
-
validateListInput(data)
|
|
74
|
-
|
|
75
|
-
return wrapSocialRequest('atproto', async () => {
|
|
76
|
-
const result = await atprotoFetch(`/xrpc/app.bsky.graph.updateList`, {
|
|
77
|
-
method: 'POST',
|
|
78
|
-
body: JSON.stringify({
|
|
79
|
-
list: id,
|
|
80
|
-
name: data.title,
|
|
81
|
-
description: data.metadata?.description
|
|
82
|
-
})
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
return transformList(result)
|
|
86
|
-
})
|
|
87
|
-
},
|
|
88
|
-
|
|
89
|
-
async deleteList(id) {
|
|
90
|
-
return wrapSocialRequest('atproto', async () => {
|
|
91
|
-
await atprotoFetch(`/xrpc/app.bsky.graph.deleteList`, {
|
|
92
|
-
method: 'POST',
|
|
93
|
-
body: JSON.stringify({ list: id })
|
|
94
|
-
})
|
|
95
|
-
})
|
|
96
|
-
},
|
|
97
|
-
|
|
98
|
-
async addItem(listId, item) {
|
|
99
|
-
validateItemInput(item)
|
|
100
|
-
|
|
101
|
-
return wrapSocialRequest('atproto', async () => {
|
|
102
|
-
const result = await atprotoFetch(`/xrpc/app.bsky.graph.addListItem`, {
|
|
103
|
-
method: 'POST',
|
|
104
|
-
body: JSON.stringify({
|
|
105
|
-
list: listId,
|
|
106
|
-
subject: item.title // ATProto uses "subject" for list entries
|
|
107
|
-
})
|
|
108
|
-
})
|
|
109
|
-
|
|
110
|
-
return transformItem(result)
|
|
111
|
-
})
|
|
112
|
-
},
|
|
113
|
-
|
|
114
|
-
async updateItem(listId, itemId, data) {
|
|
115
|
-
validateItemInput(data)
|
|
116
|
-
|
|
117
|
-
return wrapSocialRequest('atproto', async () => {
|
|
118
|
-
const result = await atprotoFetch(`/xrpc/app.bsky.graph.updateListItem`, {
|
|
119
|
-
method: 'POST',
|
|
120
|
-
body: JSON.stringify({
|
|
121
|
-
list: listId,
|
|
122
|
-
item: itemId,
|
|
123
|
-
...data
|
|
124
|
-
})
|
|
125
|
-
})
|
|
126
|
-
|
|
127
|
-
return transformItem(result)
|
|
128
|
-
})
|
|
129
|
-
},
|
|
130
|
-
|
|
131
|
-
async deleteItem(listId, itemId) {
|
|
132
|
-
return wrapSocialRequest('atproto', async () => {
|
|
133
|
-
await atprotoFetch(`/xrpc/app.bsky.graph.deleteListItem`, {
|
|
134
|
-
method: 'POST',
|
|
135
|
-
body: JSON.stringify({
|
|
136
|
-
list: listId,
|
|
137
|
-
item: itemId
|
|
138
|
-
})
|
|
139
|
-
})
|
|
140
|
-
})
|
|
141
|
-
},
|
|
142
|
-
|
|
143
|
-
async reorderItems(listId, itemIds) {
|
|
144
|
-
return wrapSocialRequest('atproto', async () => {
|
|
145
|
-
await atprotoFetch(`/xrpc/app.bsky.graph.reorderListItems`, {
|
|
146
|
-
method: 'POST',
|
|
147
|
-
body: JSON.stringify({
|
|
148
|
-
list: listId,
|
|
149
|
-
items: itemIds
|
|
150
|
-
})
|
|
151
|
-
})
|
|
152
|
-
})
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
registerListsProvider('atproto', AtprotoListsProvider)
|
package/global.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
declare function useNuxtApp(): any
|
package/index.js
DELETED