@hackersheet/core 0.1.0-alpha.1

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.
Files changed (104) hide show
  1. package/README.md +3 -0
  2. package/dist/chunk-3GXIDS5H.mjs +23 -0
  3. package/dist/chunk-5X53IRLN.mjs +2417 -0
  4. package/dist/chunk-7R3CATQT.mjs +143 -0
  5. package/dist/chunk-C3G2CMRR.mjs +13 -0
  6. package/dist/chunk-EXRG4APR.mjs +34 -0
  7. package/dist/chunk-FIFBNWMD.mjs +21 -0
  8. package/dist/chunk-FRXB4F4I.mjs +0 -0
  9. package/dist/chunk-JGQBUURE.mjs +60 -0
  10. package/dist/chunk-PA32N4A6.mjs +6 -0
  11. package/dist/chunk-PUTNZ4GU.mjs +12 -0
  12. package/dist/chunk-RRJUH3D4.mjs +0 -0
  13. package/dist/chunk-SYHSU6VH.mjs +38 -0
  14. package/dist/chunk-TXCPBPKN.mjs +12 -0
  15. package/dist/chunk-VKWT2GNZ.mjs +0 -0
  16. package/dist/chunk-WIUPPYM5.mjs +60 -0
  17. package/dist/chunk-YAN7TO2B.mjs +0 -0
  18. package/dist/chunk-ZZFAG7Y6.mjs +705 -0
  19. package/dist/client/client.d.mts +51 -0
  20. package/dist/client/client.d.ts +51 -0
  21. package/dist/client/client.js +3424 -0
  22. package/dist/client/client.mjs +20 -0
  23. package/dist/client/create-client.d.mts +11 -0
  24. package/dist/client/create-client.d.ts +11 -0
  25. package/dist/client/create-client.js +3429 -0
  26. package/dist/client/create-client.mjs +21 -0
  27. package/dist/client/operations/get-document.d.mts +15 -0
  28. package/dist/client/operations/get-document.d.ts +15 -0
  29. package/dist/client/operations/get-document.js +881 -0
  30. package/dist/client/operations/get-document.mjs +14 -0
  31. package/dist/client/operations/get-documents.d.mts +14 -0
  32. package/dist/client/operations/get-documents.d.ts +14 -0
  33. package/dist/client/operations/get-documents.js +798 -0
  34. package/dist/client/operations/get-documents.mjs +14 -0
  35. package/dist/client/operations/get-tag.d.mts +12 -0
  36. package/dist/client/operations/get-tag.d.ts +12 -0
  37. package/dist/client/operations/get-tag.js +776 -0
  38. package/dist/client/operations/get-tag.mjs +14 -0
  39. package/dist/client/operations/get-tags.d.mts +14 -0
  40. package/dist/client/operations/get-tags.d.ts +14 -0
  41. package/dist/client/operations/get-tags.js +772 -0
  42. package/dist/client/operations/get-tags.mjs +14 -0
  43. package/dist/client/operations/get-websites.d.mts +14 -0
  44. package/dist/client/operations/get-websites.d.ts +14 -0
  45. package/dist/client/operations/get-websites.js +798 -0
  46. package/dist/client/operations/get-websites.mjs +14 -0
  47. package/dist/client/operations/index.d.mts +11 -0
  48. package/dist/client/operations/index.d.ts +11 -0
  49. package/dist/client/operations/index.js +1041 -0
  50. package/dist/client/operations/index.mjs +31 -0
  51. package/dist/gql/fragment-masking.d.mts +22 -0
  52. package/dist/gql/fragment-masking.d.ts +22 -0
  53. package/dist/gql/fragment-masking.js +47 -0
  54. package/dist/gql/fragment-masking.mjs +10 -0
  55. package/dist/gql/gql.d.mts +70 -0
  56. package/dist/gql/gql.d.ts +70 -0
  57. package/dist/gql/gql.js +739 -0
  58. package/dist/gql/gql.mjs +7 -0
  59. package/dist/gql/graphql.d.mts +722 -0
  60. package/dist/gql/graphql.d.ts +722 -0
  61. package/dist/gql/graphql.js +733 -0
  62. package/dist/gql/graphql.mjs +14 -0
  63. package/dist/gql/index.d.mts +4 -0
  64. package/dist/gql/index.d.ts +4 -0
  65. package/dist/gql/index.js +761 -0
  66. package/dist/gql/index.mjs +16 -0
  67. package/dist/index.d.mts +8 -0
  68. package/dist/index.d.ts +8 -0
  69. package/dist/index.js +3429 -0
  70. package/dist/index.mjs +22 -0
  71. package/dist/types/document.d.mts +71 -0
  72. package/dist/types/document.d.ts +71 -0
  73. package/dist/types/document.js +18 -0
  74. package/dist/types/document.mjs +0 -0
  75. package/dist/types/index.d.mts +3 -0
  76. package/dist/types/index.d.ts +3 -0
  77. package/dist/types/index.js +18 -0
  78. package/dist/types/index.mjs +1 -0
  79. package/dist/types/tag.d.mts +23 -0
  80. package/dist/types/tag.d.ts +23 -0
  81. package/dist/types/tag.js +18 -0
  82. package/dist/types/tag.mjs +0 -0
  83. package/dist/types/website.d.mts +29 -0
  84. package/dist/types/website.d.ts +29 -0
  85. package/dist/types/website.js +18 -0
  86. package/dist/types/website.mjs +0 -0
  87. package/dist/utils/index.d.mts +2 -0
  88. package/dist/utils/index.d.ts +2 -0
  89. package/dist/utils/index.js +49 -0
  90. package/dist/utils/index.mjs +12 -0
  91. package/dist/utils/make-after-cursor-from-page.d.mts +3 -0
  92. package/dist/utils/make-after-cursor-from-page.d.ts +3 -0
  93. package/dist/utils/make-after-cursor-from-page.js +32 -0
  94. package/dist/utils/make-after-cursor-from-page.mjs +6 -0
  95. package/dist/utils/non-nullable-filter.d.mts +3 -0
  96. package/dist/utils/non-nullable-filter.d.ts +3 -0
  97. package/dist/utils/non-nullable-filter.js +30 -0
  98. package/dist/utils/non-nullable-filter.mjs +6 -0
  99. package/dist/utils/to-array-from-edges.d.mts +6 -0
  100. package/dist/utils/to-array-from-edges.d.ts +6 -0
  101. package/dist/utils/to-array-from-edges.js +34 -0
  102. package/dist/utils/to-array-from-edges.mjs +7 -0
  103. package/license.md +21 -0
  104. package/package.json +36 -0
@@ -0,0 +1,143 @@
1
+ import {
2
+ toArrayFromEdges
3
+ } from "./chunk-C3G2CMRR.mjs";
4
+ import {
5
+ graphql
6
+ } from "./chunk-3GXIDS5H.mjs";
7
+
8
+ // src/client/operations/get-document.ts
9
+ graphql(`
10
+ query document($slug: String) {
11
+ document(slug: $slug) {
12
+ id
13
+ slug
14
+ emoji
15
+ title
16
+ draft
17
+ content
18
+ path
19
+ tags {
20
+ edges {
21
+ node {
22
+ id
23
+ name
24
+ }
25
+ }
26
+ }
27
+ preview {
28
+ id
29
+ width
30
+ height
31
+ path
32
+ fileUrl
33
+ }
34
+ publishedAt
35
+ modifiedAt
36
+ assets {
37
+ edges {
38
+ node {
39
+ id
40
+ path
41
+ name
42
+ fileUrl
43
+ height
44
+ width
45
+ }
46
+ }
47
+ }
48
+ outboundLinkDocuments {
49
+ edges {
50
+ node {
51
+ id
52
+ slug
53
+ emoji
54
+ title
55
+ draft
56
+ path
57
+ tags {
58
+ edges {
59
+ node {
60
+ id
61
+ name
62
+ }
63
+ }
64
+ }
65
+ publishedAt
66
+ modifiedAt
67
+ }
68
+ }
69
+ }
70
+ inboundLinkDocuments {
71
+ edges {
72
+ node {
73
+ id
74
+ slug
75
+ emoji
76
+ title
77
+ draft
78
+ path
79
+ tags {
80
+ edges {
81
+ node {
82
+ id
83
+ name
84
+ }
85
+ }
86
+ }
87
+ publishedAt
88
+ modifiedAt
89
+ }
90
+ }
91
+ }
92
+ websites {
93
+ edges {
94
+ node {
95
+ id
96
+ url
97
+ domain
98
+ title
99
+ description
100
+ ogSiteName
101
+ ogTitle
102
+ ogType
103
+ ogUrl
104
+ ogDescription
105
+ ogLocale
106
+ ogImage {
107
+ id
108
+ fileUrl
109
+ width
110
+ height
111
+ }
112
+ }
113
+ }
114
+ }
115
+ }
116
+ }
117
+ `);
118
+ function makeGetDocumentResponse(result) {
119
+ if (!result.data?.document) {
120
+ return { document: null, error: result.error };
121
+ }
122
+ const tmpDoc = result.data?.document;
123
+ const document = {
124
+ ...tmpDoc,
125
+ tags: toArrayFromEdges(tmpDoc.tags?.edges),
126
+ assets: toArrayFromEdges(tmpDoc.assets?.edges),
127
+ outboundLinkDocuments: toArrayFromEdges(tmpDoc.outboundLinkDocuments?.edges).map((doc) => ({
128
+ ...doc,
129
+ tags: toArrayFromEdges(doc.tags?.edges)
130
+ })),
131
+ inboundLinkDocuments: toArrayFromEdges(tmpDoc.inboundLinkDocuments?.edges).map((doc) => ({
132
+ ...doc,
133
+ tags: toArrayFromEdges(doc.tags?.edges)
134
+ })),
135
+ websites: toArrayFromEdges(tmpDoc.websites?.edges)
136
+ };
137
+ const error = result.error;
138
+ return { document, error };
139
+ }
140
+
141
+ export {
142
+ makeGetDocumentResponse
143
+ };
@@ -0,0 +1,13 @@
1
+ import {
2
+ nonNullableFilter
3
+ } from "./chunk-PA32N4A6.mjs";
4
+
5
+ // src/utils/to-array-from-edges.ts
6
+ function toArrayFromEdges(edges) {
7
+ if (!edges) return [];
8
+ return edges.map((edge) => edge?.node).filter(nonNullableFilter) ?? [];
9
+ }
10
+
11
+ export {
12
+ toArrayFromEdges
13
+ };
@@ -0,0 +1,34 @@
1
+ import {
2
+ toArrayFromEdges
3
+ } from "./chunk-C3G2CMRR.mjs";
4
+ import {
5
+ graphql
6
+ } from "./chunk-3GXIDS5H.mjs";
7
+
8
+ // src/client/operations/get-tags.ts
9
+ graphql(`
10
+ query tags($sort: ConnectionSort) {
11
+ tags(sort: $sort) {
12
+ totalCount
13
+ edges {
14
+ node {
15
+ id
16
+ name
17
+ documentCount
18
+ documentCountInPublished
19
+ }
20
+ }
21
+ }
22
+ }
23
+ `);
24
+ function makeGetTagsResponse(result) {
25
+ const tags = toArrayFromEdges(result.data?.tags?.edges);
26
+ const totalCount = result.data?.tags?.totalCount || 0;
27
+ const isEmpty = totalCount === 0;
28
+ const error = result.error;
29
+ return { tags, totalCount, isEmpty, error };
30
+ }
31
+
32
+ export {
33
+ makeGetTagsResponse
34
+ };
@@ -0,0 +1,21 @@
1
+ // src/gql/fragment-masking.ts
2
+ function getFragmentData(_documentNode, fragmentType) {
3
+ return fragmentType;
4
+ }
5
+ function makeFragmentData(data, _fragment) {
6
+ return data;
7
+ }
8
+ function isFragmentReady(queryNode, fragmentNode, data) {
9
+ const deferredFields = queryNode.__meta__?.deferredFields;
10
+ if (!deferredFields) return true;
11
+ const fragDef = fragmentNode.definitions[0];
12
+ const fragName = fragDef?.name?.value;
13
+ const fields = fragName && deferredFields[fragName] || [];
14
+ return fields.length > 0 && fields.every((field) => data && field in data);
15
+ }
16
+
17
+ export {
18
+ getFragmentData,
19
+ makeFragmentData,
20
+ isFragmentReady
21
+ };
File without changes
@@ -0,0 +1,60 @@
1
+ import {
2
+ toArrayFromEdges
3
+ } from "./chunk-C3G2CMRR.mjs";
4
+ import {
5
+ graphql
6
+ } from "./chunk-3GXIDS5H.mjs";
7
+
8
+ // src/client/operations/get-documents.ts
9
+ graphql(`
10
+ query documents($after: String, $first: Int, $filter: DocumentConnectionFilter, $sort: ConnectionSort) {
11
+ documents(after: $after, first: $first, filter: $filter, sort: $sort) {
12
+ totalCount
13
+ edges {
14
+ node {
15
+ id
16
+ slug
17
+ emoji
18
+ title
19
+ draft
20
+ path
21
+ tags {
22
+ edges {
23
+ node {
24
+ id
25
+ name
26
+ }
27
+ }
28
+ }
29
+ preview {
30
+ id
31
+ width
32
+ height
33
+ path
34
+ fileUrl
35
+ }
36
+ publishedAt
37
+ modifiedAt
38
+ }
39
+ }
40
+ }
41
+ }
42
+ `);
43
+ function makeGetDocumentsResponse(result) {
44
+ if (!result.data || !result.data.documents) {
45
+ return { documents: [], totalCount: 0, isEmpty: true, error: result.error };
46
+ }
47
+ const tmpDocs = result.data.documents;
48
+ const documents = toArrayFromEdges(tmpDocs?.edges).map((document) => ({
49
+ ...document,
50
+ tags: toArrayFromEdges(document.tags?.edges)
51
+ }));
52
+ const totalCount = result.data?.documents?.totalCount || 0;
53
+ const isEmpty = totalCount === 0;
54
+ const error = result.error;
55
+ return { documents, totalCount, isEmpty, error };
56
+ }
57
+
58
+ export {
59
+ makeGetDocumentsResponse
60
+ };
@@ -0,0 +1,6 @@
1
+ // src/utils/non-nullable-filter.ts
2
+ var nonNullableFilter = (value) => value != null;
3
+
4
+ export {
5
+ nonNullableFilter
6
+ };
@@ -0,0 +1,12 @@
1
+ // src/utils/make-after-cursor-from-page.ts
2
+ function makeAfterCursorFromPage(page, first) {
3
+ const after = (page - 1) * first;
4
+ if (after === 0) {
5
+ return void 0;
6
+ }
7
+ return Buffer.from(after.toString()).toString("base64");
8
+ }
9
+
10
+ export {
11
+ makeAfterCursorFromPage
12
+ };
File without changes
@@ -0,0 +1,38 @@
1
+ import {
2
+ toArrayFromEdges
3
+ } from "./chunk-C3G2CMRR.mjs";
4
+ import {
5
+ graphql
6
+ } from "./chunk-3GXIDS5H.mjs";
7
+
8
+ // src/client/operations/get-tag.ts
9
+ graphql(`
10
+ query tag($name: String) {
11
+ tag(name: $name) {
12
+ id
13
+ name
14
+ documentCount
15
+ documentCountInPublished
16
+ relatedTags {
17
+ edges {
18
+ node {
19
+ id
20
+ name
21
+ documentCount
22
+ documentCountInPublished
23
+ }
24
+ }
25
+ }
26
+ }
27
+ }
28
+ `);
29
+ function makeGetTagResponse(result) {
30
+ const tmpTag = result.data?.tag;
31
+ const tag = tmpTag ? { ...tmpTag, relatedTags: toArrayFromEdges(tmpTag.relatedTags?.edges) } : null;
32
+ const error = result.error;
33
+ return { tag, error };
34
+ }
35
+
36
+ export {
37
+ makeGetTagResponse
38
+ };
@@ -0,0 +1,12 @@
1
+ import {
2
+ Client
3
+ } from "./chunk-5X53IRLN.mjs";
4
+
5
+ // src/client/create-client.ts
6
+ function createClient(options) {
7
+ return new Client(options);
8
+ }
9
+
10
+ export {
11
+ createClient
12
+ };
File without changes
@@ -0,0 +1,60 @@
1
+ import {
2
+ toArrayFromEdges
3
+ } from "./chunk-C3G2CMRR.mjs";
4
+ import {
5
+ graphql
6
+ } from "./chunk-3GXIDS5H.mjs";
7
+
8
+ // src/client/operations/get-websites.ts
9
+ graphql(`
10
+ query websites($after: String, $first: Int) {
11
+ websites(after: $after, first: $first) {
12
+ totalCount
13
+ edges {
14
+ node {
15
+ id
16
+ url
17
+ domain
18
+ title
19
+ description
20
+ ogSiteName
21
+ ogTitle
22
+ ogType
23
+ ogUrl
24
+ ogDescription
25
+ ogLocale
26
+ ogImage {
27
+ id
28
+ fileUrl
29
+ width
30
+ height
31
+ }
32
+ documents {
33
+ edges {
34
+ node {
35
+ id
36
+ draft
37
+ title
38
+ slug
39
+ }
40
+ }
41
+ }
42
+ }
43
+ }
44
+ }
45
+ }
46
+ `);
47
+ function makeGetWebsitesResponse(result) {
48
+ const websites = toArrayFromEdges(result.data?.websites?.edges).map((website) => ({
49
+ ...website,
50
+ documents: toArrayFromEdges(website.documents?.edges)
51
+ }));
52
+ const totalCount = result.data?.websites?.totalCount || 0;
53
+ const isEmpty = totalCount === 0;
54
+ const error = result.error;
55
+ return { websites, totalCount, isEmpty, error };
56
+ }
57
+
58
+ export {
59
+ makeGetWebsitesResponse
60
+ };
File without changes