aboutsummaryrefslogtreecommitdiff
path: root/src/api/schema.peechy
blob: 1c21c7d5e6100e45b093838aae59d0dbf87ea0af (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
package Api;

smol Loader {
    jsx = 1;
    js = 2;
    ts = 3;
    tsx = 4;
    css = 5;
    file = 6;
    json = 7;
}

smol ResolveMode {
  disable = 1;
  lazy = 2;
  dev = 3;
  bundle = 4;
}

smol Platform {
  browser = 1;
  node = 2;
}

smol JSXRuntime {
  automatic = 1;
  classic = 2;
}

struct JSX {
  string factory;
  JSXRuntime runtime;
  string fragment;
  bool development;

  // Probably react
  string import_source;

  bool react_fast_refresh;
}

struct StringPointer {
  uint32 offset;
  uint32 length;
}

struct JavascriptBundledModule {
  // package-relative path including file extension
  StringPointer path;
  StringPointer code;
  uint32 package_id;

}

struct JavascriptBundledPackage {
  StringPointer name;
  StringPointer version;
  uint32 hash;

  uint32 modules_offset;
  uint32 modules_length;
}

struct JavascriptBundle {
  // This has to be sorted by ${package_prefix}path
  JavascriptBundledModule[] modules;
  JavascriptBundledPackage[] packages;

  byte[] etag;
  // this will be a u64, but that data type doesn't exist in this schema format
  uint32 generated_at;
  // generated by hashing all ${name}@${version} in sorted order
  byte[] app_package_json_dependencies_hash;
  byte[] import_from_name;
  // This is what StringPointer refers to 
  byte[] manifest_string;
}

message JavascriptBundleContainer {
  uint32 bundle_format_version = 1;
  JavascriptBundle bundle = 2;
  // Don't technically need to store this, but it may be helpful as a sanity check
  uint32 code_length = 3;
}

smol ScanDependencyMode {
  app = 1;
  all = 2;
}

smol ModuleImportType {
  import = 1;
  require = 2;
}

struct ModuleImportRecord {
  ModuleImportType kind;
  string path;

  bool dynamic;
}

struct Module {
  string path;
  ModuleImportRecord[] imports;
}

message TransformOptions {
  JSX jsx = 1;
  string tsconfig_override = 2;
  ResolveMode resolve = 3;

  string public_url = 4;
  string absolute_working_dir = 5;


  string[] define_keys = 6;
  string[] define_values = 7;

  bool preserve_symlinks = 8;

  string[] entry_points = 9;
  bool write = 10;

  string[] inject = 11;
  string output_dir = 12;

  string[] external = 13;

  string[] loader_keys = 14;
  Loader[] loader_values = 15;

  string[] main_fields = 16;
  Platform platform = 17;

  bool serve = 18;

  string[] extension_order = 19;

  string public_dir = 20;

  ScanDependencyMode only_scan_dependencies = 21;

  bool generate_node_module_bundle = 22;
}

struct FileHandle {
  string path;
  uint size;
  uint fd; 
}

message Transform {
  FileHandle handle = 1;
  string path = 2;
  byte[] contents = 3;

  Loader loader = 4;
  TransformOptions options = 5;
}

enum TransformResponseStatus {
  success = 1;
  fail = 2;
}

struct OutputFile {
  byte[] data;
  string path;
}

struct TransformResponse {
  TransformResponseStatus status;
  OutputFile[] files;
  Message[] errors;
}

enum MessageKind {
  err = 1;
  warn  =2;
  note = 3;
  debug = 4;
}

struct Location {
  string file;
  string namespace;
  int32 line;
  int32 column;
  string line_text;
  string suggestion;
  uint offset;
}

message MessageData {
  string text = 1;
   Location location = 2;
}

struct Message {
  MessageKind kind;
  MessageData data;
  MessageData[] notes;
}

struct Log {
  uint32 warnings;
  uint32 errors;
  Message[] msgs;
}